How to use Term Facet query with multivalue fields?

I have a document with multivalue fields:

But when I run a facet query on it:

Each term value returns a total count of 1, even though the count should be
more than that:

  1. What's the right way to setup the document data or mappings in order to
    measure the count of the term facets accurately?
    https://gist.github.com/pulkitsinghal/5447250#file-_mapping-json

  2. Perhaps its the query that needs to be tweaked?

  • Pulkit

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

A TermsFacet counts the number of docs, not the number of terms per doc or field.

Perhaps, you can use a script to render it, but I'm not sure of that.
See Elasticsearch Platform — Find real-time answers at scale | Elastic

curl http://localhost:9200/index/_search?pretty -d '
{
"query" : {
"match_all" : { }
},
"script_fields" : {
"tag" : {
"script" : "doc["field_name"].values.length"
}
}
}'

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 23 avr. 2013 à 22:58, pulkitsinghal pulkitsinghal@gmail.com a écrit :

I have a document with multivalue fields:
Multivalue field and facet query - unexpected results... · GitHub

But when I run a facet query on it:
Multivalue field and facet query - unexpected results... · GitHub

Each term value returns a total count of 1, even though the count should be more than that:
Multivalue field and facet query - unexpected results... · GitHub

  1. What's the right way to setup the document data or mappings in order to measure the count of the term facets accurately?
    Multivalue field and facet query - unexpected results... · GitHub

  2. Perhaps its the query that needs to be tweaked?

  • Pulkit

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

On Tue, Apr 23, 2013 at 4:09 PM, David Pilato david@pilato.fr wrote:

A TermsFacet counts the number of docs, not the number of terms per doc or
field.

Ok, so I started again in a different index with the mapping set to nested:
"properties" : {
"bought_together" : {
"type" : "nested"
}
}

So I've effectively changed the mapping from:

to

Now that its indexing it as a nested document, I would expect the term
facet count to function so once again I run:

But there is still some gap in my understanding because I don't get any
results:
facets: {
tag: {
_type: terms
missing: 1
total: 0
other: 0
terms:
}
}

Thoughts? Tips?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.