Understading Solr nested queries

前端 未结 3 714
温柔的废话
温柔的废话 2021-01-23 22:11

I\'m trying to understand solr nested queries but I\'m having a problem undestading the syntax.

I have the following two indexed documents (among others):



        
相关标签:
3条回答
  • 2021-01-23 22:52

    Need to remove the "=" and replace it with ":" to use the nested query syntax:

    q="Fulano Silva"~2 AND _query_:"{!edismax qf=city}fortaleza" &defType=edismax&qf=name&fl=score

    *Use _query_: instead of _query_=

    Hope this works...

    0 讨论(0)
  • 2021-01-23 23:00

    EDIT: When you say q=, are you specifying the query in a URL, or is the text after the q= being put in an application or the Solr dashboard? If we're talking about a URL, you may need to use percent-encoding to get it to work. I mentioned that below, but since I haven't heard from you, I thought I'd reiterate.

    Why don't you do q=name:"Fulano Silva" AND city:"fortaleza"?

    Another possibility: q=_query_:"{!edismax qf='name'}Fulano Silva" AND city:"fortaleza"

    If you're set on a nested query, select?defType=edismax&q="Fulano Silva" AND _query_:"{!edismax qf='city' v='fortaleza'}" should work, but the results and the way it matches will depend on what analyzers you are using to query and index name and city. Also, if these queries are in your query string, make sure you are encoding them properly.

    In order to help you any more, I need to know what you're trying to accomplish with your query. Then perhaps we can be sure you have the right indexing set up, that edismax is the right query handler, etc.

    0 讨论(0)
  • 2021-01-23 23:01

    On top of the previous comments, the asker has mispelled _query_ as __query__ (note the double underscore in the second, mispelled, version); Solr expects _query_ to be spelled with only one underscore (_) before and one after the word query, not two.

    0 讨论(0)
提交回复
热议问题