11

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.

Selwyn
  • 1,621
  • 6
  • 21
  • 38

2 Answers2

15

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.

Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275
8

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 ... )

tweep
  • 91
  • 1
  • 4