Multi Field query with query_string over property and nested object

(Marcus) #1

I'm trying to solve the following high level requirement:

  • save arbitrary number of key value pairs on a document with properties: name and description
  • values can be numbers which should be 'range searchable'
  • values can include geo_points which need to be 'geo searchable'

I've created the following index.

{ "settings": { "index" : { "number_of_shards" : 3, "number_of_replicas" : 1 } }, "mappings": { "_doc": { "dynamic": "strict", "properties": { "name": { "type": "text", "analyzer": "german", }, "description": { "type": "text", "analyzer": "german" }, "attributes": { "type": "nested", "properties": { "key": { "type": "text" }, "val_bool": { "type": "boolean" }, "val_int": { "type": "integer" }, "val_float": { "type": "float" }, "val_string": { "type": "text" }, "val_geo": { "type": "geo_point" }, "val_date": { "type": "date" } } } } } } }

We use nested objects to be able to save a list of key-value-pairs for each document. Each key-value-pair uses one typed val_* property to persist the value.

To search in documents we use query_string query to allow users to be very specific in searches. For example. Search documents where name:foo AND description:bar. (that works as expected)

The same scenario should be possible with key-value-pairs.So for example:
attributes.key:someKey AND attributes.val_string:someStringValue.
This scenario requires a nested query which we use and works as expected.

What isnt't working:
If we search for name:foo AND attributes.key:someKey we get no results.

It's seems that 'nested query_string queries' AND 'just query_string queries' arent't supported in combination. Is that true?
What's a feasible workaround to implement the described requirement?

Any help is greatly appreciated. Thank you in advance.

(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.