使用RavenDB和lucene在字符串数组中的每个元素中搜索多个术语 [英] Search each element in string array for multiple terms using RavenDB and lucene

查看:113
本文介绍了使用RavenDB和lucene在字符串数组中的每个元素中搜索多个术语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我(除其他外)在我的RavenDB中拥有以下对象:

I have (among others) the follwing objects in my RavenDB:

Object1:

{
  "Texts" : [ "one two", "three four" ]
}

Object2:

{
  "Texts" : [ "one three", "two four" ]
}

我想找到所有对象,其中Texts中的字符串包含术语onetwo.

I want to find all objects where a string in Texts contains both of the terms one and two.

如果我将该字段编入索引

If I index the field

from doc in docs.Objects select new { Texts }

并使用StandardAnalyzer分析它,当我只想Object1时,以下查询将同时返回Object1Object2:

and analyze it using the StandardAnalyzer the following query will return both Object1 and Object2 when I only want Object1:

Texts:(one AND two)

我该如何解决?

推荐答案

如果您需要这样做,可以这样做:

If you need it that way, you can do:

from doc in docs
from text in doc.Tests
select new { Text = text }

请注意,这是一个扇出索引,如果每个文档中有很多文本,则需要注意所需的资源.

Note that this is a fan-out index, and if you have a lot of texts per document, that require paying attention to the resources required.

这篇关于使用RavenDB和lucene在字符串数组中的每个元素中搜索多个术语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆