Hello there! I don't have good experience in using elastic and I want to know if my structure is reasonable and adequate.
Problem:
I have "computers" index
{
"mappings": {
"properties": {
"cpu": {"type": "keyword"},
"ram_size": {"type": "integer"},
"disk_size": {"type": "integer"}
}
}
}
And I created "percolator-queries" index to store different queries that is used to filter computers by different characteristics. For example, query that filters computers that have intel cpu and ram 32gb:
PUT percolator-queries/_doc/intel_32
{
"query" : {
"query_string" : {
"query" : "cpu: intel AND ram:32"
}
},
"computers": []
}
As you can see, there is array property called computers. I added it to store computer ids that matches to my query.
And then when I add new computer, I search if there is matching percolator query. If my new document suits to query I update computers property in matched percolator query document. (I add id of new computer to computers ).
POST percolator-queries/_update/intel_32
{
"script": {
"source": "ctx._source.computers.addAll(params.val)",
"lang": "painless",
"params": {
"val": [id_of_my_computer]
}
}
}
With that structure I can just extract percolator query document by its id (intel_32 in my case) and return ids of suitable computers, then use returned ids for whatever I want.
Is that reasonable to use percolator index like this? Or there are other ways to solve my problem?