Как применить Boolean (должен, должен) в выделенной части эластичного поиска? - PullRequest
0 голосов
/ 02 июля 2019

Я пытаюсь применить must / must в запросе, но выделенная часть не дала желаемого результата.В справочникеasticsearch я узнал, что Highlighters don’t reflect the boolean logic of a query when extracting terms to highlight, но я хочу применить логическую логику в своем выделении.Как это сделать?

Это мой индекс

PUT myindex/_doc/1
{
    "name" : "ram",
    "lastname" : "asb",
    "job_description" : "Systems administrator and Linux specialit",
   "sections":[
       {
         "text":"  provided, that Holdings may incur Indebtedness  or issue shares of Disqualified Stock, and any Restricted Subsidiary may incur Indebtedness  and issue shares of Disqualified Stock and any Restricted Subsidiary that is not the Issuer or a Subsidiary Guarantor may issue shares of Preferred Stock, if (i) the  on a consolidated basis of Holdings and its Restricted Subsidiaries for the most recently ended four fiscal quarters for which internal financial statements are available immediately preceding the date on which such additional Indebtedness is incurred or such Disqualified Stock or Preferred Stock is issued would  (ii) the Consolidated  on a consolidated basis of Holdings and its Restricted Subsidiaries for the most recently ended four fiscal quarters for which internal financial statements are available immediately preceding the date on which such additional Indebtedness is incurred or such  been equal"
       },
       {
         "text":"Indebtedness incurred pursuant to any by Holdings or any Restricted Subsidiary and the  and creation of  and bankers’ acceptances thereunder ; provided that immediately after giving effect to any such incurrence or issuance (including pro forma application of the net proceeds therefrom), the then outstanding aggregate principal amount of all Indebtedness incurred or issued under this clause (1) does not exceed the sum  an additional amount after all amounts have been incurred under clause (1)(a), if after giving pro forma effect to the incurrence of such additional amount (including a pro forma application of the net proceeds therefrom), the Consolidated  would have been equal; provided that for purposes of determining the amount that may be incurred under this clause (1)(b) only, all Indebtedness incurred under this clause (1)(b) shall be deemed to be included in clause (1) of the definition of “Consolidated "
       }
    ] 
} 

Это мой запрос

GET myindex/_search
{
  "_source": false, 
  "query":{
    "nested":{
      "path": "sections",
      "query":{
        "bool":{
          "must": [
            {
               "match":{"sections.text":"Consolidated"}
            },
            {
               "match":{"sections.text":"forma"}
            }
          ]
        }
      }
    }
  },
    "highlight": {
       "fragment_size" : 200,
      "no_match_size": 0, 
        "fields" : {
          "sections.text" : {}
        }
    }
}

Иэто мой вывод

"hits" : [
      {
        "_index" : "myindex",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.3312968,
        "highlight" : {
          "sections.text" : [
            "on a <em>consolidated</em> basis of Holdings and its Restricted Subsidiaries for the most recently ended four fiscal quarters for which internal financial statements are available immediately preceding the date",
            "by Holdings or any Restricted Subsidiary and the  and creation of  and bankers’ acceptances thereunder ; provided that immediately after giving effect to any such incurrence or issuance (including pro <em>forma</em>",
            "principal amount of all Indebtedness incurred or issued under this clause (1) does not exceed the sum  an additional amount after all amounts have been incurred under clause (1)(a), if after giving pro <em>forma</em>",
            "effect to the incurrence of such additional amount (including a pro <em>forma</em> application of the net proceeds therefrom), the <em>Consolidated</em>  would have been equal; provided that for purposes of determining",
            "the amount that may be incurred under this clause (1)(b) only, all Indebtedness incurred under this clause (1)(b) shall be deemed to be included in clause (1) of the definition of “<em>Consolidated</em>"
          ]
        }
      }
    ]

Мы можем ясно видеть, что он не выдаст вывод как (объединенная форма AND)

Если кто-то запросит AND b

GET index1/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "FIELD": "a"
          }
        },
        {
          "match": {
            "FIELD": "b"
          }
        }
      ]
    }
  },
    "highlight": {
       "fragment_size" : 200,
      "no_match_size": 0, 
        "fields" : {
          "sections.text" : {}
        }
    }
}

Мое желание будет равно

"hits" : [
      {
        "_index" : "myindex",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.371541,
        "highlight" : {
          "sections.text" : [
            "fgfg <em>a</em> fgrgth <em>b</em>"
         ]
        }
      }
    ]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...