A user requested assistance with using the dal query to get a specific data index for a particular service on a given device. Another user explained the differences between "match" and "term" operators and how to use them in Elastic Search queries. The requested help was provided.
Read the entire ‘Understanding "match" and "term" Operators in Elastic Search’ thread below:
I think this is something an API pro would be able to rattle off quickly. I am trying to use the dal query to get a specific data index and its really a struggle. I need to return the status of a specific service for a specific device so I can get that data and pass it to my next step in the workflow. here is what I have so far:
“`{
"meta": { "source": "DebugSpoolerQueryUppercaseMatch" },
"data_query": {
"size": 10,
"from": 0,
"sort": [{ "_created": "desc" }],
"query": {
"bool": {
"must": [
{ "match": { "name": "Spooler" } },
{ "match": { "device_name": "[device.domain.COM](http://device.domain.COM)" } }
]
}
}
}
}“`
https://api.controlup.com/edge/api/dal/builtin_services2
but its not getting the services from the right device
it just returns the list of devices with spooler
any help would be very much appreciated!
So when I need to make Elastic Search queries, I just describe the index to and what I’m looking for
“`{
"meta": { "source": "DebugSpoolerQueryUppercaseMatch" },
"data_query": {
"size": 10,
"from": 0,
"sort": [{ "_created": "desc" }],
"query": {
"bool": {
"must": [
{ "term": { "name.keyword": "Spooler" } },
{ "term": { "device_name.keyword": "CCLEAR-LT.WORKGROUP" } }
]
}
}
}
}“`
You gave him a fish
match = fuzzy matching
term = exact matching
keyword because by default Elastic Search (ES) will tokenize text.
CCLEAR-LT.WORKGROUP turns into cclear, lt, workgroup. With a match operator that would return other workgroup devices, other laptops, etc.
Term tells ES to not tokenize the search input.
Keyword tells ES to use the raw value of the field, not the tokenized value.
You need both for exact text matching
awesome thank you guys!!
Continue reading and comment on the thread ‘Understanding “match” and “term” Operators in Elastic Search’. Not a member? Join Here!
Categories: All Archives
