Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr search query for dynamic fields indexed

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.

like image 687
Selwyn Avatar asked Jun 02 '11 10:06

Selwyn


2 Answers

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.

like image 110
Mauricio Scheffer Avatar answered Oct 08 '22 12:10

Mauricio Scheffer


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

like image 27
user1452447 Avatar answered Oct 08 '22 13:10

user1452447