Help my please realized clarifying filtering

GET original_docs/_search
{
  "_source": [
    "styles",
    "production_date_start"
  ],
  "from": 20,
  "size": 20,
  "query": {
    "bool": {
      "filter": [
        {
          "nested": {
            "path": "styles",
            "query": {
              "terms": {
                "styles.name": [
                  "Gothic"
                ]
              }
            }
          }
        }
      ]
    }
  }
}

result

{
        "_index" : "original_docs",
        "_type" : "_doc",
        "_id" : "77",
        "_score" : 0.0,
        "_source" : {
          "production_date_start" : 1402,
          "styles" : [
            {
              "name" : "Gothic"
            },
            {
              "name" : "Renaissance"
            }
          ]
        }
      },

When I add another value

"terms": {
                "styles.name": [
                  "Gothic",
                 "Renaissance"
                ]
              }

So I need that as a result there were documents where the styles field necessarily contained ["Gothic","Renaissance"] or other fields ["Gothic","Renaissance" ...], now it doesn't work like that, the results are displayed where there are only "Gothic" or "Renaissance" and ["Gothic","Renaissance" ...] only 3 variants are needed.

POST /_scripts/painless/_execute
{
  "script": {
    "source": "int matches=0; for(String item : params.haystack){if(params.finds.contains(item)){matches++}} if(params.finds.length === matches) return params.haystack",
    "params": {
      "finds": ["Gothic", "Northern Renaissance"],
      "haystack": ["Gothic", "Northern Renaissance", "Ottonian"]
    }
  }
}

This script fulfills my needs, but I can't add it to GET _search, I have a problem with doc['styles.name'] there, for some reason it only returns one element.

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