Strange result of search children by parent


(maxkazar) #1

I need find all children by parent id. In my case i have notifications and
each notification has documents.

I try to search all documents for some notifications like this

{
"fields": [
"highlight",
"_parent"
],
"query": {
"bool": {
"must": [
{
"terms": {
"_parent": [
"4fadd2c31f48d548f5000001",
"4faf79c61f48d548f1000006",
"4fae27eb1f48d55f68000006",
"4fadf6f61f48d54820000002",
"4fae39911f48d57e3f000002",
"4fae42681f48d52b6f000001",
"4faf79c61f48d548f1000005",
"4fadf0c41f48d534eb000024",
"4fae11381f48d5586400000a",
"4fae07611f48d55cae000014"
],
"minimum_match": 1
}
}
],
"should": [
{
"query_string": {
"fields": [
"content"
],
"query": "test"
}
}
]
}
},
"highlight": {
"fields": {
"content": {
"fragment_size": 100,
"number_of_fragments": 1,
"order": "score"
}
}
}
}

and every time result is different. One time result contain 3 items and
second 5 items. ElasticSearch has to nodes with 10 shards (version 1.9.3)

I simplified search query:
{
"fields": [
"name"
],
"query": {
"term": {
"_parent": "4fae3e3d1f48d5261c000033"
}
}
}

result the same, return one document or nothing


(maxkazar) #2

I think i found a solution of my problem. Now i send query with preference
_only_node:xyz where xyz is id master node. When i set _primary or
_primary_first result is empty. Why is it necessary to specify node id in
preference for right result?


(maxkazar) #3

It's strange:

search query

{
"fields": [
"highlight",
"_parent"
],
"query": {
"bool": {
"must": [
{
"terms": {
"_parent": [
"4fadd2c31f48d548f5000001",
"4faf79c61f48d548f1000006",
"4fae27eb1f48d55f68000006",
"4fadf6f61f48d54820000002",
"4fae39911f48d57e3f000002",
"4fae42681f48d52b6f000001",
"4faf79c61f48d548f1000005",
"4fadf0c41f48d534eb000024",
"4fae11381f48d5586400000a",
"4fae07611f48d55cae000014"
],
"minimum_match": 1
}
}
],
"should": [
{
"query_string": {
"fields": [
"content"
],
"query": "test"
}
}
]
}
},
"highlight": {
"fields": {
"content": {
"fragment_size": 100,
"number_of_fragments": 1,
"order": "score"
}
}
}
}

  1. Search without preference - 2 or 3 result items, (first 2 then 3) and
    item is unique
  2. Search with preference = _primary - each result empty
    3, Search with _only_node:xyz - 5 item result contains 2 and 3 result item
    from first step

Screenshot of my elasticseach head

https://lh5.googleusercontent.com/-tIMUrVahwLc/T7jDDZ0vLZI/AAAAAAAAAJw/JmYOcr1W14Q/s1600/Screenshot+from+2012-05-20+14%3A01%3A18.png


(maxkazar) #4

xyz - is id of Bulldozer (master)


(system) #5