Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform a search in a Multivalued Field in Solr?

I'm having dificulties to execute a search in Solr. My Solr has a Multivalued field like this document below:

<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. 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. 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

like image 613
Thiago Avatar asked Jul 08 '12 23:07

Thiago


People also ask

What is multivalued field in SOLR?

multiValued. If true, indicates that a single document might contain multiple values for this field type.

What is multivalued field?

What Does Multivalued Field (MVF) Mean? A multivalued field (MVF) allows for the storage of more than one value in a database field. MVFs are somewhat controversial, with many arguing that they violate one of the very sacred tenets of database design as laid out by E.F.


3 Answers

Try something like this:
series:("The Walking Dead" OR "Game of Thrones")

like image 91
silviu.ct Avatar answered Oct 19 '22 13:10

silviu.ct


In addition to @user1452132 's answer -

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.

The query formed would be series:the OR text:(Walking Dead)

You can debug the Query using the debugQuery=on in your request url.

You can use Dismax query handler to make it more manageable.

like image 33
Jayendra Avatar answered Oct 19 '22 11:10

Jayendra


Use in fq parameter (filter query),

E.g

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

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

Solr url encoding:

  • ':' become '%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

like image 32
user218867 Avatar answered Oct 19 '22 11:10

user218867