How do I search within an array field?
I am using solr 4.2 with default settings.
I indexed a few html and pdf documents using SolrNet. Here is a sample result for such a document when I search using the admin search *:*
enter code here
<doc>
<str name="id">2</str>
<date name="last_modified">2011-12-19T17:33:25Z</date>
<str name="author">name</str>
<str name="author_s">name</str>
<arr name="title">
<str>CALIFORNIA CODES</str>
</arr>
<arr name="content_type">
<str>application/pdf</str>
</arr>
<str name="resourcename">T01041.pdf</str>
<arr name="content">
<str> PDF text here </str>
</arr>
<long name="_version_">1431314431195742208</long>
</doc>
The search using content:*
returns 0 results.
Instead of content:*
try with content:[* TO *]
. That will fetch all documents that have the field content
non-empty.
For querying arrays/multi-valued fields, it depends on what you want to do. If you have a multi-valued field like:
<arr name="tag_names">
<str>death</str>
<str>history</str>
<str>people</str>
<str>historical figures</str>
<str>assassinations</str>
</arr>
and you want to find documents having both death
and history
as tag_names
then issue a query like
q=tag_names:(death AND history)
To do an OR, use
q=tag_names:(death OR history)