Вопрос

I have defined in Elastic Search the following mapping for my index with one multi_field type.

{
    'station': {
       "properties" :{
           'id': {'type': 'integer'},
           'call': {'type': 'multi_field', 
                    'fields' : {
                               'call': {'type': 'string', 'analyzer': 'whitespace'},
                               'raw': {'type': 'string', 'index': 'not_analyzed'}
                               }
                    }
        }
    }
}

I like Mozilla's ElasticUltis, but I couldn't find a way to query the multi_field fields.

I would have expected something like:

myQuery = S.query(call_raw__wildcard="value")

Does anyone know how to Query a multi_field field with elasticutils?

Это было полезно?

Решение 2

Ok - I found a work around in the multi_field docs (tnx @DrTech). If "path":"just_name" is added, the field (in the question "call.raw") can be accessed without the "call" prefix. Then the mapping would look like this:

{
'station': {
   "properties" :{
       'id': {'type': 'integer'},
       'call': {'type': 'multi_field', 
                'path' : 'just_name',
                'fields' : {
                           'call': {'type': 'string', 'analyzer': 'whitespace'},
                           'raw': {'type': 'string', 'index': 'not_analyzed'}
                           }
                }
    }
}

}

Unfortunately, it's just a workaround. Maybe someone else has a better idea?

Другие советы

First, your multi_field definition is incorrect. You should have a call main field at the same level as raw and autocomplete. See the multi_field docs.

Then you can query the main field as call, and the raw field as call.raw.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top