Solr search query for dynamic fields indexed

♀尐吖头ヾ 提交于 2019-11-27 23:04:43

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

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