0

All terms in the query should be present in the combined content of the fields. E.g. when I search for a combination of terms a document should be returned if:

  • all terms are present in the 'description' field, the 'metadata' field or both fields
  • or all terms are distributed over both fields (e.g. one term is present in the 'description' field and the two remaining terms are present in the 'metadata' field)

So q.op=AND but across two separate fields. How should I write my query?

What if I change the indexing to use a single multivalue field instead of two separate fields, does that make this scenario easier?

Michiel van Oosterhout
  • 22,839
  • 15
  • 90
  • 132

1 Answers1

3

Yup, you can combine the two fields into a single multivalued field using copyfield.

<copyField source="metadata" dest="metadata_desc" />
<copyField source="descrition" dest="metadata_desc" />

The query can be formed with q=metadata_desc:"some search"&q.op=AND

With q.op the search for all the terms would be mandatory and should match for a document to be returned. The default is OR.

This will take care of matching it in either of the fields as well as across the fields.

Jayendra
  • 52,349
  • 4
  • 80
  • 90