It doesn't work, the result is:
{"term":"bbb","count":2},
{"term":"aaa","count":1 },
{"term":"ccc","count":1 }
于 2014年07月08日 02:07, Harish Ved 写道:
Did you try the following query?
"query":{
    "filtered" : {
        "filter" : {
            "bool" : {
                "should" : [
                    {"term" : { "field_B" : "aaaa" }},
                    {"term": {"field_B": "bbb"}}
                ]
            }
        }
    }
  },
    "facets" : {
        "tag" : {
            "terms" : {
                "field" : "field_A"
            }
        }
    }
}


Plz confirm if it works for you.

On Monday, 7 July 2014 15:56:53 UTC+5:30, 闫旭 wrote:

    Dear All!
    I have some docs:
    {"field_A":"aaa","field_B":"bbb"}
    {"field_A":"aaa","field_B":"ccc"}
    {"field_A":"bbb","field_B":"bbb"}
    {"field_A":"bbb","field_B":"bbb"}
    {"field_A":"bbb","field_B":"eee"}
    {"field_A":"aaa","field_B":"aaaa"}
    {"field_A":"ccc","field_B":"aaaa"}
    first step:
    {
      "query":{
        "filtered" : {
            "filter" : {
                "bool" : {
                    "must" : {
                        "term" : { "field_B" : "bbb" }
                    }
                }
            }
        }
      },
        "facets" : {
            "tag" : {
                "terms" : {
                    "field" : "field_A"
                }
            }
        }
    }
    first result:
    {
    ...
    {"term":"aaa","count":1},
    {"term":"bbb","count":2},
    ...
    }
    -------------------------------------------------------------------------
    second step:
    the second facets:
    {
      "query":{
        "filtered" : {
            "filter" : {
                "bool" : {
                    "must" : {
                        "term" : { "field_B" : "aaaa" }
                    }
                }
            }
        }
      },
        "facets" : {
            "tag" : {
                "terms" : {
                    "field" : "field_A"
                }
            }
        }
    }
    second result:
    {
    ...
    {"term":"aaa","count":1}.
    {"term":"ccc","count":1}
    ...
    }
    
-----------------------------------------------------------------------------
    third step:
    combine the two result with interesction operation with "term":
    {"term":"aaa","count":"I don't care the count value."}

    
-----------------------------------------------------------------------------
    Now, How can i combine the three steps in one filter facets or
    othen method??


    Thx All!!

--
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 [email protected] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/93d5adb6-bcd1-49b6-8c28-be4d456f92d8%40googlegroups.com <https://groups.google.com/d/msgid/elasticsearch/93d5adb6-bcd1-49b6-8c28-be4d456f92d8%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/53BB51CC.3080005%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to