Exists query

Dear all,

I am a complete newbie, so I am sorry if this is a trivial question.
The question is: why does the 'exists' query (see below) not work??

I did do a search and read the documentation and I have the idea that I am overlooking something quite simple, but I just don't seem to see what it is...

What I do is this:

  1. I make a new column in an existing index (where the type is 'article'):
    $ curl -XPUT http://myElasticSearchUrl:9280/myIndex/article/_mapping -d '{
    "article" : {
    "properties" : {
    "myMFCol" : {
    "type": "multi_field",
    "fields" : { "myField1" : { "type": "string",
    "index" : "analyzed"},
    "myField2" : { "type": "string",
    "index" : "analyzed"}
    }
    }
    }
    }
    }'

  2. I add a document, with the new field
    $ curl -XPUT http://myElasticSearchUrl:9280/myIndex/article/myMFId1 -d '{
    "articleurl": "http://www.blabla.nl",
    "text": "Bla bla"s bla bla",
    "myMFCol" : {"myField1": "Check value 1",
    "myField2" : "Check value 2" }
    }'

  3. Check that it worked:
    $ curl -XGET http://myElasticSearchUrl:9280/myIndex/article/myMFId1
    {"_index":"myIndex","_type":"article","_id":"myMFId1","_version":2,"exists":true, "_source" : {
    "articleurl": "http://www.blabla.nl",
    "text": "Bla bla"s bla bla",
    "myMFCol" : {"myField1": "Check value 1",
    "myField2" : "Check value 2" }
    }}

  4. Then I tty to get all documents that have this field
    $ curl -XGET http://myElasticSearchUrl:9280/myIndex/article/_search -d '{ "filter" : { "exists" : {"field" : "myMFCol" } }
    {"took":14,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

?!?
So I would expect to get this 1 document here, but I get none.

Why not?

Any help appreciated!

Cheers,

Tom

Right, and to follow up on myself... I should have done more digging because the answer is here:

http://elasticsearch-users.115913.n3.nabble.com/Exists-Filter-doesn-t-work-with-objects-td3932787.html

In short, it doesn't work because the field I was trying to find out for if it existed or not is an 'object'. Or well, something that is not indexed as such anyway.

So the solution would be to add an additional column to the document (a simple integer or string field) that indicates whether or not the other field exists.

Just in case anybody knows a more elegant way doing this, I would be delighted to hear about it!