Reputation: 1940
How can i search inside array of a multivalued field
My Data is like this
<str name="Key">8</str>
<arr name="city">
<str>Achabal (NAC)</str>
<str>Addi Gam</str>
<str>Adeh Hall</str>
<str>Aho Paisan</str>
<str>Akin Gam</str>
<str>Akura</str>
.......
</arr>
<str name="state">Chandigarh</str>
I want to search inside city filed i am trying the query as below
q=city:*Ak* AND state:Chandigarh <br>
But not working
Above mentioned data is single document
Upvotes: 1
Views: 8134
Reputation: 2764
Multivalued fields have no difference with monovalued field (from query perspective). Note that in your query there's an error: SOLR doesn't support using a * symbol as the first character of a search.
See links below
http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.ReversedWildcardFilterFactory
http://solr.pl/en/2010/12/20/wildcard-queries-and-how-solr-handles-them
http://www.solrtutorial.com/solr-query-syntax.html
Upvotes: 2
Reputation: 557
You should not use & in your query but + or %20 (space) instead. & separates url query parameters and state stuff will not be passed as value for q.
Try q=city:*Ak*+state:Chandigarh
or q=city:*Ak* state:Chandigarh
.
What you also probably would like to do is use filter query instead of query parameter here:
q=city*Ak*&fq=state:Chandigarh
This will query for all cities with 'Ak' and limit results only to ones with state='Chandigarh'
Upvotes: 0