Hi all,

I'm having some difficulties running queries with multiple nested filters. 
Consider the following mapping:

{
    "template" : "products",
    "mappings" : {
        "Product" : {
        "dynamic" : "false",
            "properties" : {
                "id" : {
                    "type" : "long"
                },
                "name" : {
                    "type" : "string",
                    "analyzer" : "standard"
                },
                "reviews" : {
                    "type" : "nested",
                    "dynamic" : "false",
                    "properties" : {
            "positive" : { 
            "type" : "nested",
            "dynamic" : "false",
            "properties" : {
            "reviewCount" : {
                    "type" : "integer"
                },
            "keywords" : {
            "type" : "nested",
            "dynamic" : "false",
            "properties" : {
            "id" : {
                    "type" : "long"
                },
                "name" : {
                    "type" : "string",
                    "analyzer" : "standard"
                 },
                 "score": { 
            "type": "double" 
             },
             "frequency": { 
             "type": "integer" 
             }
            }
            }
            }
            },
            "negative" : { 
            "type" : "nested",
            "dynamic" : "false",
            "properties" : {
            "reviewCount" : {
                    "type" : "integer"
                },
            "keywords" : {
            "type" : "nested",
            "dynamic" : "false",
            "properties" : {
            "id" : {
                    "type" : "long"
                },
                "name" : {
                    "type" : "string",
                    "analyzer" : "standard"
                 },
                 "score": { 
            "type": "double" 
             },
             "frequency": { 
             "type": "integer" 
             }
            }
            }
            }
            }
          }
                }
            }
        }
    }
}

Running the following query:

NestedFilterBuilder idFilter = nestedFilter( "reviews.positive.keywords", 
filteredQuery( matchAllQuery(), termFilter( "reviews.positive.keywords.id", 
id ) ) );
NestedFilterBuilder scoreFilter = nestedFilter( 
"reviews.positive.keywords", filteredQuery( matchAllQuery(), rangeFilter( 
"reviews.positive.keywords.score" ).from( score ).includeLower( true ) ) );

RangeFilterBuilder productScoreFilter = rangeFilter( "score" ).from( 
productScore ).includeLower( true );

SearchResponse searchResponse = esClient.prepareSearch( "products" ).
setQuery( filteredQuery( matchAllQuery(), andFilter( productScoreFilter, 
idFilter, scoreFilter ) ) ).
setSize( 40000 ).
get();

The returned hits contain results with wrong score, i.e. score lower than 
what configured at scoreFilter. Seems like other filters are working 
perfect. Am I using the wrong way to apply multiple nested filters?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/cb007c0e-0aa2-4aec-b88c-db53407d114e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to