2

I have these documents:

{"title": "aa","cast": ["a","b","c","a"]}
{"title": "bb","cast": ["a","b","c","b"]}
{"title": "cc","cast": ["a","b","c","c"]}

I get the result using the faceting.

facets": {
      "cast_result": {
         "_type": "terms",
         "missing": 0,
         "total": 9,
         "other": 0,
         "terms": [
            {
               "term": "c",
               "count": 3
            },
            {
               "term": "b",
               "count": 3
            },
            {
               "term": "a",
               "count": 3
            }
         ]
      }
  }
}

but I want the result that the count of "a" is four,Because the frequency of "a" is four in the real document."b" and "c" also like the "a".

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Can you post the full query of this ? Also the analyzer applied for "cast" – Duc.Duong Mar 04 '15 at 08:37
  • The cast uses the standard analyzer. The query code: POST /index_test/_search?search_type=count { "facets": { "cast_result": { "terms": { "field": "cast" } } } } – Luoluo Flly Mar 04 '15 at 09:31
  • Seem that it try to return count of document rather than the term frequency itself. I'm trying some other methods to see if it help – Duc.Duong Mar 04 '15 at 10:52
  • Looking forward to your good news. – Luoluo Flly Mar 05 '15 at 01:09
  • This links may help you: http://stackoverflow.com/questions/13217849/elasticsearch-return-term-frequency-of-a-single-field, https://github.com/jprante/elasticsearch-index-termlist – Duc.Duong Mar 11 '15 at 02:50

1 Answers1

0

create the index

query

the sum of term is the answer

But I find a question ,when the number of the shards is more than 2, the answer is wrong ,so it must be lower than 2.It doesn't matter about the number of replicas.