동 방법"A"또는"empty"

0

질문

나는 다음과 같은 index

{
  "docs": {
    "mappings": {
      "text": {
        "properties": {
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
          "code": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}

""코드 값을 가질 수 있습:["a"],["b"],["a","b"]또는[]

필요한 쿼리를 해소하는 값으로 코드:"a"또는[]. 사람이 도움이 될 수 있습니다 이 쿼리,여기에 무엇이 내가 지금까지 시도 w/밖으로 성공을(이 말은"a"AND"[]";고 싶은""또는"[]").

"bool": {
  "should": [
    {
      "match": {
        "code": "a"
      }
    }
  ],
  "must_not": [
    {
      "exists": {
        "field": "code"
      }
    }
  ]
}
  
elasticsearch elasticsearch-dsl
2021-11-18 20:21:18
1

최고의 응답

0

거나 달성될 수 있으로 bool/should하지만, bool/must 제약 조건이 있어야 합 내부 bool/should.

당신이 질

{
  "query": {
    "bool": {
      "minimum_should_match": 1,
      "should": [
        {
          "match": {
            "code": "a"
          }
        },
        {
          "bool": {
            "must_not": [
              {
                "exists": {
                  "field": "code"
                }
              }
            ]
          }
        }
      ]
    }
  }
}
2021-11-18 21:25:31

감사합니다,이 작품! 아 나 너무 가까이 있었고,아직까지는 나의 원래의 쿼리
Test1 Test2

멋진 기꺼이 그것을 밖으로 일했다!!
Val

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................