djangoelasticsearchelasticutils

Query Multi_Field with Elasticutils


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?


Solution

  • 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?