简体   繁体   English

如何在Solr中的多值字段中执行搜索?

[英]How to perform a search in a Multivalued Field in Solr?

I'm having dificulties to execute a search in Solr. 我很难在Solr中执行搜索。 My Solr has a Multivalued field like this document below: 我的Solr有一个多值字段,如下文所示:

<int name="id">2166324592435</int>
...others fields
<arr name="Series">
   <str>The Walking Dead<\str>
   <str>Game of Thrones<\str>
<\arr>

The Multivalued field Series has the Tv serie which the document references. 多值字段系列具有文档引用的Tv系列。 In the example above, my document says about The Walking Dead and Game of Thrones. 在上面的例子中,我的文档描述了“行尸走肉”和“权力的游戏”。 I can have documents with one, two or more series or even no series. 我可以拥有一个,两个或更多系列甚至没有系列的文档。

What I want to do is search in Solr. 我想要做的是在索尔搜索。 I want to give the series that I want and Solr should returns the documents that says about my query. 我想给出我想要的系列,Solr应该返回关于我的查询的文档。 I tryed but I couldn't do it. 我试过但我不能这样做。 I tryed the following: 我尝试了以下方法:

q=series:The Walking Dead or series:Game of Thrones or ...&wt=json

I think I'm doing wrong. 我想我做错了。 What's the correctly way to do it? 这样做的正确方法是什么?

Thanks in advance 提前致谢

Thiago 蒂亚戈

尝试这样的事情:
series:("The Walking Dead" OR "Game of Thrones")

In addition to @user1452132 's answer - 除了@ user1452132的回答 -

When you are searching q=series:The Walking Dead , only the is searched across the series field while the walking dead is search across the default search field. 当你正在寻找q=series:The Walking Dead ,只有the搜索整个系列领域,而walking dead跨越默认搜索字段搜索。

The query formed would be series:the OR text:(Walking Dead) 形成的查询将是系列:OR文本:(行尸走肉)

You can debug the Query using the debugQuery=on in your request url. 您可以使用请求URL中的debugQuery = on调试Query。

You can use Dismax query handler to make it more manageable. 您可以使用Dismax查询处理程序使其更易于管理。

Use in fq parameter (filter query), fq参数中使用(过滤查询),

Eg 例如

    name:("Java" OR "Python")
    name:("Java" AND "Web")

    // multivalued fields
    author_ids:(1733 OR 58)
    author_ids:(1733 AND 58)

Solr url encoding: Solr url编码:

  • ':' become '%3A' ':'成为'%3A'
  • space become '+' 空间变成'+'

Thus, you might get a url like this: 因此,您可能会得到这样的网址:

http://localhost:8983/solr/xxx/select?q=programming&fq=title%3A ("Java"+AND+"web")&wt=json&indent=true&defType=edismax&qf=title&stopwords=true&lowercaseOperators=true http:// localhost:8983 / solr / xxx / select?q =编程&fq =标题%3A (“Java”+ AND +“web”)&wt = json&indent = true&defType = edismax&qf = title&stopwords = true&lowercaseOperators = true

Depending on what the intent of the search is try the following two searches 根据搜索的意图,尝试以下两次搜索

series:"The Walking Dead" OR series:"Game of Thorns" 系列:“行尸走肉”OR系列:“荆棘游戏”

series:(The Walking Dead) OR series:(Game of Thorns) 系列:(行尸走肉)OR系列:(荆棘游戏)

Please read solr query syntax and the underlying Lucene query syntax 请阅读solr查询语法和底层Lucene查询语法

I think your the actual problem is using OR as lowercase. 我认为你的实际问题是使用OR作为小写。 When you do something like that, The or value is searched in defaultTextField . 当您执行类似的操作时,将在defaultTextField搜索or值。 Also don't forget to put quotes if there's a whitespace in your query - and you're looking for an exact match. 如果查询中有空格,也不要忘记放置引号 - 而且您正在寻找完全匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM