0

I have a json block saved as one document in solr,

{
    "internal":...
    "internet":...
    "interface":...
    "noise":...
    "noise":...
}

Could I seach as " inter*:* "? I want to find out all content with key start with "inter"

Unfortunately, I got parser error, is there any way that I could the search with a wildcard in the key?

Neil
  • 2,714
  • 11
  • 29
  • 45

2 Answers2

0

You can use Dynamic fields. It allow Solr to index fields that you did not explicitly define in your schema.

This is useful if you discover you have forgotten to define one or more fields. Dynamic fields can make your application less brittle by providing some flexibility in the documents you can add to Solr.

A dynamic field can be defined like

<dynamicField name="*_i" type="int" indexed="true"  stored="true"/>

Please refer solr documentation for more on Dynamic Fields. Dynamic Fields

After this create a copy field. Copy the dynamic fields into the copy field.

Once done with this, query can be done on the copyField.

<dynamicField name="inter_*" type="string" indexed="true" stored="true"/>
<field name="internal_static" type="string" indexed="true" stored="true" multiValued="true"/>
<copyField source="inter_*" dest="emp_static"/>
Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47
0

No, not really. You'll have to do that as a copyField if providing a wildcard is important to you, in effect copying everything into a single field and then querying that field.

You can supply multiple fields through qf without specifying each field in the q parameter as long as you're using the edismax query handler - that's usually more flexible, but it will still require each field to be specified.

There's also a little known feature named "Field aliasing using per-field qf overrides" (I'm wasn't aware with it, at least). If I've parsed what I've been able to find from a few web searches correctly, you should be able to do f.i_fields.qf=internal internet interface&qf=i_fields. In effect creating an i_fields alias that refers to those three fields. You'll still have to give them explicitly.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84