Hello,
I'm now indexing some newspaper documents. I have created some object fields in my index that collect all the entities founded in the text field and its frequencies in the same text field, E.G.:
"people": [ { "count": 2, "value": "Ermanno" }, { "count": 2, "value": "Anna Finocchiaro" }, { "count": 2, "value": "Roberto Calderoli" }, { "count": 2, "value": "Silvio Berlusconi" }, { "count": 2, "value": "Denis Verdini" }, { "count": 2, "value": "Paolo Romani" }, { "count": 2, "value": "Juncker" }, { "count": 2, "value": "Federica Mogherini" }, { "count": 4, "value": "Angela Merkel" }, { "count": 2, "value": "Matteo Renzi" }, { "count": 2, "value": "Junker" }, { "count": 2, "value": "Beppe Grillo" }, { "count": 4, "value": "Giancarlo Galan" }, { "count": 2, "value": "Myrta Merlino" }, { "count": 2, "value": "Yara Gambirasio" }, { "count": 2, "value": "Francesco Dettori" }, { "count": 2, "value": "John Kerry" }, { "count": 2, "value": "Obama" }, { "count": 2, "value": "Putin" }, { "count": 2, "value": "Kuchma" }, { "count": 6, "value": "Prandelli" }, { "count": 2, "value": "Cesare" }, { "count": 2, "value": "Chiellini" }, { "count": 2, "value": "Pirlo" }, { "count": 2, "value": "Balotelli" } ]
the mapping settings are these ones:
"people":{ "properties": { "count": { "type": "integer", "doc_values": true, "index": true }, "value":{ "type": "text", "analyzer": "namedentities_analyzer", "fielddata": true } } }
Now I would like to make a query to retrieve all the people entity found in all the newspapers of the last two months and order them by the sums of their frequencies count. Something like this:
value: Bergoglio, sum_of_count: 256, doc_count:200
value: Berlusconi, sum_of_count: 239, doc_count: 180,
etc....
How i can do that? I have to change my data structure?