I have a unit test where I insert a lot of profiles into my Elasticsearch
index and then execute some different searching queries against the index.
After indexing I refresh using:
client.admin().indices().refresh(refreshRequest("_all")).actionGet();
After my tests the index is deleted using:
client.admin().indices().prepareDelete("searching").execute().actionGet();
The strange thing is that sometimes all my tests are executed successfully
and sometimes some of them fail - the reason being that the expected list
of profiles does not match the actual list of profiles.
One example I have seen is when i search for profiles having audio true
using a query like this:
{
"query" : {
"filtered" : {
"query" : { "match_all": {} },
"filter" : { "and": { "filters": [ { "term": { "audio": true } } ] } }
}
}
}
Then I get back the following three profiles:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 1,
"hits": [
{
"_index": "searching",
"_type": "profiles",
"_id": "9",
"_score": 1,
"_source": {
"id": "9",
"provider": "en_DK_TEST",
"operator": "en_DK_TEST",
"msisdn": "11111112",
"nickname": "ANNA",
"age": 35,
"hasGender": true,
"gender": "FEMALE",
"sexPref": "FEMALE",
"location": "31.Test2.etc",
"interests": [
"party"
],
"picture": false,
"video": false,
"audio": true,
"online": false,
"lastActivity": 1356068041004,
"joinDate": 1356068038885
}
},
{
"_index": "searching",
"_type": "profiles",
"_id": "2",
"_score": 1,
"_source": {
"id": "2",
"provider": "en_DK_TEST",
"operator": "en_DK_TEST",
"msisdn": "33333333",
"nickname": "JENS",
"age": 60,
"hasGender": true,
"gender": "MALE",
"sexPref": "FEMALE",
"location": "32",
"picture": false,
"video": false,
"audio": true,
"online": false,
"lastActivity": 1356068040990,
"joinDate": 1356068038838
}
},
{
"_index": "searching",
"_type": "profiles",
"_id": "10",
"_score": 1,
"_source": {
"id": "10",
"provider": "en_DK_TEST",
"operator": "en_DK_TEST",
"msisdn": "11111113",
"nickname": "BRENDA",
"age": 25,
"hasGender": true,
"gender": "FEMALE",
"sexPref": "BOTH",
"picture": false,
"video": false,
"audio": true,
"online": false,
"lastActivity": 1356053641006,
"joinDate": 1356053638891
}
}
]
}
}
BUT Henry actually has audit true as well - at least that is what I see
when I query him using:
{
"query" : {
"filtered" : {
"query" : { "match_all": {} },
"filter" : { "and": { "filters": [ { "term": { "nickname": "henry" }
} ] } }
}
}
}
I get:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "searching",
"_type": "profiles",
"_id": "1",
"_score": 1,
"_source": {
"id": "1",
"provider": "en_DK_TEST",
"operator": "en_DK_TEST",
"msisdn": "22222222",
"nickname": "HENRY",
"age": 56,
"hasGender": true,
"gender": "MALE",
"sexPref": "FEMALE",
"location": "31",
"interests": [
"party",
"music"
],
"picture": false,
"video": true,
"audio": true,
"online": true,
"lastActivity": 1356080952448,
"joinDate": 1356080950416
}
}
]
}
}
Why isn't Henrik part of the search result when I search for audio true then?
Would be really great if someone had some kind of idea of what could be going on here.
Thanks a lot,
Stine
--