There are many cases where you will want to ask for a particular field value. For example, when searching for the author of a book in the Internet library or an e-commerce shop. Of course Solr can do that, and this recipe will show you how to do it.
Let's start with the following index structure (just add the following to your
schema.xml
file to the field definition section):<field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="title" type="text" indexed="true" stored="true" /> <field name="author" type="string" indexed="true" stored="true"/>
To ask for a value in the author field, send the following query to Solr:
http://localhost:8983/solr/select?q=author:rafal
That's all. The documents you'll get from Solr will be the ones with the requested value in the author
field. Remember that the query shown in the example uses the standard query parser, not DisMax.