Dear Professional,
I have a Search string like below
index="hcg_oapi_prod" relatedPersons
| regex "\"relatedPersons\":\[\]"
And this is the result
The result have to type:
Type 1: Results has value {"name":{"firstName":"xxx","middleName":"xxx","lastName":"xxx"}
Type 2: Results dose not have value {"name":{"firstName":"xxx","middleName":"xxx","lastName":"xxx"}
How can I filter results for type 2 only? (dose not have value {"name":{"firstName":"xxx","middleName":"xxx","lastName":"xxx"})
Thank you.
As I said, it's using AND for those the words, so neither of those two records have 'middleName', so it is not ignored. If you want to use OR, then add OR between each of the words
Note that NOT searches are not the most efficient, but you could do
index="hcg_oapi_prod" relatedPersons NOT (firstName middleName lastName)
| regex "\"relatedPersons\":\[\]"
That is doing AND between the 3 words and then NOT those, so all have to be present for those events to be ignored.
As I said, it's using AND for those the words, so neither of those two records have 'middleName', so it is not ignored. If you want to use OR, then add OR between each of the words