I would like to be able to search all fields for a certain string and get
all distinct matching key value pairs as a result. It should also be
possible to add filters/queries to constrain the results. The original data
consists of millions of documents and a few thousand possible keys so I
simplified the data into the example below.
Mapping
{
"example_index": {
"example_type": {
"properties": {
"name": {"type":"string"},
"description": {"type":"string"},
"gender": {"type":"string"}
}
}
}
}
Data
{
"name": "John",
"job": "pilot",
"gender": "male"
},
{
"name": "Eric",
"job": "pilot",
"gender": "male"
},
{
"name": "Marie",
"job": "ceo",
"gender": "female"
}
Needed results
For example searching all fields for “ma” should return:
{
"gender": "male", (1x)
"gender": "female",
"name": "Marie"
}
Searching all fields for “ma” in combination with the query “job”: ”pilot”,
should return only:
{
"gender": "male" (1x)
}
Aggregation
With the aggregation framework this would partly be possible with the
following code:
{
"from" : "0",
"size" : "0",
"query": {
"match" : {
"job": "pilot"
}
},
"aggs" : {
"test" : {
"terms" : {
"field" : "_all",
"include" : ".ma."
}
}
}
}
But it only returns the unique values without the keys.
Does anyone have a suggestion to get the needed distinct key value pairs
with the aggregation framework or an other option in Elasticsearch?
--
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/33dd2dda-ddb3-4b41-b7f1-fa62aee76ef9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.