第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在彈性搜索PHP包中使用“And”運(yùn)算符進(jìn)行搜索

在彈性搜索PHP包中使用“And”運(yùn)算符進(jìn)行搜索

PHP
眼眸繁星 2022-08-19 15:35:09
我正在嘗試在php作曲家包的幫助下學(xué)習(xí)。我有一個(gè)名稱包含,字段。我想有基于上述字段的過濾器,它應(yīng)該在運(yùn)算符中。我目前的查詢代碼是:Elastic Searchindexmedia_datanits_accountnits_urlsession_idtimestampand$items = $this->elasticsearch->search([    'index' => $index_name,    'body'  => [        'query' => [            'filtered' => [                'filter' => [                    'and' => [                        ['match' => ['nits_account' => 'xyzABCD2190-aldsj']],  //API Key                        ['match' => ['nits_url' => 'google.com']],                    ]                ]            ]        ]    ]]);我的問題:我無法獲取數(shù)據(jù)。但是如果我做下面的代碼:$items = $this->elasticsearch->search([    'index' => $index_name,    'body'  => [        'query' => [             'bool' => [                'should' => [                    ['match' => ['nits_account' => $account] ],                    ['match' => ['nits_url' => $domain] ],                ],            ],         ]    ]]);我在運(yùn)算符中獲取值,但需要在其中具有操作。orand我怎么能有不同的搜索操作與各自的字段,我的意思是我想有字段是完全匹配的,我想有喜歡/通配符操作,時(shí)間戳應(yīng)該是可比的(大于/小于/在兩個(gè)日期之間)。nits_accountnits_url菲律賓比索彈性搜索elasticsearch-php
查看完整描述

1 回答

?
largeQ

TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊

試試這個(gè):


$items = $this->elasticsearch->search([

    'index' => $index_name,

    'body'  => [

        'query' => [

             'bool' => [

                'must' => [

                    ['match' => ['nits_account' => $account] ],

                    ['match' => ['nits_url' => $domain] ]

                ],

            ], 

        ]

    ]

]);

您應(yīng)該使用關(guān)鍵字,而不是關(guān)鍵字。 行為類似于 AND 操作,而作用類似于 OR 操作。mustshouldmustshould


請(qǐng)參閱此 https://stackoverflow.com/a/28768600/5430055


如果需要使用條件匹配,請(qǐng)使用如下內(nèi)容:


"query": {

    "bool": {

      "must": [

        {

          "range": {

            "nits_url": {

              "gte": 1000,

              "lte": 10000

            }

          }

        },

        {

          "match": {

            "nits_account": "$account"

          }

        }

      ]

    }

  }


查看完整回答
反對(duì) 回復(fù) 2022-08-19
  • 1 回答
  • 0 關(guān)注
  • 122 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)