I am implementing the solr search in my project .
I have one question regarding how do i search a dynamic fields that is created in a solr index
Eg:- this is the tag that is formed in the index
And I am trying to search from solr using this query Employee_* = 172
Please help me in this if the way of searching is incorrect.
In your queries, you need to define exactly what concrete fields you want to search, e.g. Employee_a
, Employee_b
(or whatever dynamic fields you've used). You can't search in all dynamic fields by using wildcards in a field name in queries.
Here's a work-around :
- create a (static) copyField
- copy the dynamic field into the (static) copyField
- query the copyField
Your schema.xml could look like this:
<dynamicField name="Employee_*" type="string" indexed="true" stored="true"/>
<field name="emp_static" type="string" indexed="true" stored="true" multiValued="true"/>
<copyField source="Employee_*" dest="emp_static"/>
Now you can query solr via :
select?q=emp_static:"172"
You can even tweak it and not store/index the dynamic field (as you might not query on it ... )