Solr search query for dynamic fields indexed

寵の児 提交于 2019-11-26 23:15:10

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/6213184/solr-search-query-for-dynamic-fields-indexed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!