Elastic Search Query to match Only if Specific value is present

Hi,

I have data like below

{
  "instance": {
    "items": [
      {
        "name": "name_1"
      },
      {
        "name": "name_2"
      }
    ]
  }
}

items is an array and it can contains many values.
I am looking for a query to match only if

items.name = "name_1" is specific to one value

Doc 1

{
  "instance": {
    "items": [
      {
        "name": "name_1"
      },
      {
        "name": "name_1"
      }
    ]
  }
}

Doc 2

{
  "instance": {
    "items": [
      {
        "name": "name_2"
      },
      {
        "name": "name_2"
      }
    ]
  }
}

Doc 3

{
  "instance": {
    "items": [
      {
        "name": "name_1"
      },
      {
        "name": "name_2"
      }
    ]
  }
}

example

  1. if items.name = name_1 , it should only return Doc_1
  2. if items.name = name_2, it should only return Doc_2
  3. if items.name = name_1, name_2, then it should return all three Docs.

Hi,

As far as I know there is no native function to negate terms. Boolean query logic is for documents.

I suppose you need script or something to do that.

This is a related post.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.