I think you should index it as a value in your document.
POST /articles/article
{"title" : "One", "tags" : ["foo"], "size": 1}
POST /articles/article
{"title" : "Two", "tags" : ["foo", "bar"], "size": 2}
POST /articles/article
{"title" : "Three", "tags" : ["foo", "bar", "baz"], "size": 3}
It will be really efficient.
That said, you could probably use a field script to compute it live: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-script-fields.html#search-request-script-fields and this for sorting: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_script_based_sorting
HTH
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr
Le 29 avril 2014 à 00:10:17, eunever32@gmail.com (eunever32@gmail.com) a écrit:
Hi
If I have a list in each document and I want to get the document id plus the size of the list eg
POST /articles/article
{"title" : "One", "tags" : ["foo"]}
POST /articles/article
{"title" : "Two", "tags" : ["foo", "bar"]}
POST /articles/article
{"title" : "Three", "tags" : ["foo", "bar", "baz"]}
So One will have a count of: 1
article Two has a count of: 2
Three has a count of: 3
Is that something the facets can do?
Actually I want the result ordered by count
and indexed by document id so something like:
"_id" , count
"osweUJq0Ts6BrlIGETLXpA", 1
"Fi8eBgZHQjOLWQwQESJqCw", 2
"EQBHVcPuSce1kNUZXhFtMw", 3
In other words retrieve all documents along with "size of tags" order by size of tags (ascending or descending)
Thanks in advance
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/74be4adf-d72f-4033-bb40-40f45d8c83ee%40googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.535ed3bb.614fd4a1.16bd1%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.