0

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?

dh1tw
  • 1,411
  • 2
  • 23
  • 29

2 Answers2

0

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.

DrTech
  • 17,031
  • 5
  • 54
  • 48
  • Thanks for pointing out the mistake in my multi_field definition. I have updated the definition accordingly. Unfortunately, ElasticUtils does not allow `myQuery=S.query(call.raw__wildcard="value")`. So I'm still wondering if there is a way with ElasticUtils to access the "call.raw" field – dh1tw Feb 03 '14 at 13:43
  • No idea about ElasticUtils - I'd look at using the official Python client http://www.elasticsearch.org/guide/en/elasticsearch/client/python-api/current/index.html - it exposes the full Elasticsearch API so you don't have to work around the client implementation. – DrTech Feb 03 '14 at 13:57
0

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?

dh1tw
  • 1,411
  • 2
  • 23
  • 29