内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

ES的查詢關(guān)鍵詞解釋

2023-12-04    分類: 網(wǎng)站建設(shè)

1.match

查詢語法如下:title是需要查詢的字段名,可以被替換成任何字段。query對應的是所需的查詢。比如這里會被拆分成‘php’和‘后臺’,因為operator是or,所以ES會去所有數(shù)據(jù)里的title字段查詢包含‘后臺’和‘php’的,如果operator為and,這查詢的是即包含‘后臺’又有‘php’的數(shù)據(jù),這應該很好理解。

$response = $client->get('localhost:9200/accounts/person/_search', [    'json' => [        'query' => [            'match' => [                'title' => [                    'query' => '后臺php',                    'operator' => 'or',                ]            ]        ]    ]]);

2.multi_match

如果想在多個字段中查找,那就需要用到multi_match查詢,語法如下:

$response = $client->get('localhost:9200/accounts/person/_search', [    'json' => [        'query' => [            'multi_match' => [                'query' => '張三 php',                'fields' => ['title', 'desc', 'user']            ]        ]    ]]);

3.query_string

查詢語法如下:類似match查詢的operator,在這里需要在query中用OR或AND實現(xiàn)。

$response = $client->get('localhost:9200/accounts/person/_search', [    'json' => [        'query' => [            'query_string' => [                'query' => '(張三) OR (php)',                'default_field' => 'title',            ]        ]    ]]);

多字段查詢?nèi)缦拢?/strong>

$response = $client->get('localhost:9200/accounts/person/_search', [    'json' => [        'query' => [            'query_string' => [                'query' => '(張三) OR (php)',                'fields' => ['title', 'user'],            ]        ]    ]]);

4.range query

這是范圍查詢,例如查詢年齡在10到20歲之間的。查詢語法如下:

$response = $client->get('localhost:9200/accounts/person/_search', [    'json' => [        'query' => [            'range' => [                'age' => [                    'gte' => 10,                    'lte' => 20,                ],            ]        ]    ]]);

注:gte表示>=,lte表示<=,gt表示>,lt表示<。

5.bool查詢

bool查詢的語法都是一樣的。如下:

$response = $client->get('localhost:9200/accounts/person/_search', [    'json' => [        'query' => [            'bool' => [                'must/filter/should/must_not' => [                    [                        'query_string' => [                            'query' => '研發(fā)',                        ]                    ],                    [                        'range' => [                            'age' => [                                'gt' => 20                            ]                        ]                    ],                ],            ]        ]    ]]);

當前文章:ES的查詢關(guān)鍵詞解釋
當前鏈接:http://www.rwnh.cn/news6/298606.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站動態(tài)網(wǎng)站、網(wǎng)站收錄、標簽優(yōu)化Google、網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

海丰县| 收藏| 临猗县| 安阳市| 镇坪县| 衢州市| 游戏| 乌拉特前旗| 昆明市| 新干县| 道真| 利辛县| 静安区| 泸州市| 石家庄市| 房山区| 讷河市| 南澳县| 聊城市| 武清区| 通江县| 汕尾市| 北票市| 东阿县| 建瓯市| 天长市| 得荣县| 乌恰县| 女性| 安乡县| 麻栗坡县| 峨山| 庆阳市| 淮北市| 邳州市| 报价| 吴桥县| 基隆市| 格尔木市| 淮北市| 仪陇县|