Is anyone here really good with elasticsearch? The docs are so dense, I don't know where to begin. I want to search for entities ranked on degree of overlap of their tags, i.e. if I store a bunch of documents with tags 1:{X,Y,Z}, 2:{A,B,C}, 3:{Z} and I query with {X,Z}, I get 1,3,2 in order. What api should I use? Also, I'm wondering if it's able to handle tag autocompletion, or should I roll my own?
>>60127909
If i understand correct then you need to make an aggregation of the count of the tags field.
You would get something like this.
Count of z: 23, x:2, y:0
>>60127909
>>60128903
Just got home.
Here is a query that will do what i wrote.{
"size": 0,
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "Z",
"analyze_wildcard": true
}
},
{
"range": {
"@timestamp": {
"gte": 1493470976809,
"lte": 1493485376809,
"format": "epoch_millis"
}
}
}
],
"must_not": []
}
},
"_source": {
"excludes": []
},
"aggs": {
"2": {
"terms": {
"field": "tags.raw",
"size": 10,
"order": {
"_count": "desc"
}
}
}
}
}
>>60129215
This is time based but just remove it or only take the "aggs"
Pro tip: Install Kibana and use it to do the aggs you want, it can show you the query it made and you can copy that to your program.
do you fags use elasticsearch as a general purpose db or just to store and process logs ?
>>60129408
Guess general purpose.
Use it for device syslogs and for performance, div metrics etc, anything where we can use the different aggs.
>>60128903
>>60129215
thanks for that... will take me a bit to understand, but it gives me a clue which parts of the rather huge api to focus on
>>60129408
i'm making a marketplace using postgres as primary db and elasticsearch for matching buyers and sellers appropriately.