使用elasticsearch-php需要注意的match_all和mapping问题_戴国进的博客-CSDN博客_php es match_all


本站和网页 https://blog.csdn.net/JineD/article/details/107042717 的作者无关,不对其内容负责。快照谨为网络故障时之索引,不代表被搜索网站的即时页面。

使用elasticsearch-php需要注意的match_all和mapping问题_戴国进的博客-CSDN博客_php es match_all
使用elasticsearch-php需要注意的match_all和mapping问题
戴国进
于 2020-06-30 15:04:00 发布
9599
收藏
分类专栏:
ElasticSearch
原文链接:https://blog.csdn.net/LJFPHP/article/details/89525114
版权
ElasticSearch
专栏收录该内容
31 篇文章
6 订阅
订阅专栏
一、前言       最近在把ELK升级到7.0之后,发现使用的ES-PHP并不兼容7.0的版本,可能作者正在努力开发新版本中吧。不过身为使用者,目前还是尽量少用7.0的一些新特性吧,兼容旧版本的ES还是可以的。
二、问题
1、使用match_all报错
(1)报错信息:
{"error":{"root_cause":[{"type":"parsing_exception","reason":"[match_all] query malformed, no start_object after query name","line":1,"col":45}],"type":"parsing_exception","reason":"[match_all] query malformed, no start_object after query name","line":1,"col":45},"status":400} 错误原因是: 查询格式错误,查询名称后没有start_object(没错,是有道翻译的),很奇怪,在网络上看到很多直接使用这种方式进行全文搜索的,但是用ES-PHP就不行。
    GET /_search {     "query": {         "match_all": {}     } } 2、问题改进
      突然想起来刚开始看ES-PHP文档的时候就说过,PHP是采用数组的方式拼接DSL,不能有空数组,因为问题就在于 PHP 会自动把 "content" : {} 转换成 "content" : [] ,在 Elasticsearch DSL 中这样的数据格式是非法的。我们需要告诉 PHP 那个空对象就是一个空对象而非空数组。
那么改进为:
                 "match_all"=> new \stdClass() 官方手册:https://www.elastic.co/guide/cn/elasticsearch/php/current/php_json_objects.html
3、google一下
在网上也发现有人提过这个issues,开发团队给出的建议是:
"match_all"=> (object)[]    //也是给出空数组的方式 github讨论:https://github.com/elastic/elasticsearch-php/issues/495
三、更新mapping的时候报错
就像标题一样,当我尝试更新mapping的时候,报错了,错误如下:
Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true 1、原因
      随着 7.0 版本的即将发布,type 的移除也是越来越近了,在 6.0 的时候,已经默认只能支持一个索引一个 type 了,7.0 版本新增了一个参数 include_type_name ,即让所有的 API 是 type 相关的,这个参数在 7.0 默认是 true,不过在 8.0 的时候,会默认改成 false,也就是不包含 type 信息了,这个是 type 用于移除的一个开关。
参考:https://elasticsearch.cn/article/601
      大概意思就是ES版本更新的问题,现在的type已经不用那么明显的指定出来了。查看官方的更新mapping操作,在DSL里面也没有明确的指出type。但是对于ES-PHP,因为不兼容最新的es7.0,所以更改mapping要求必须带有type,源码如下:
//源码在 vendor\elasticsearch\elasticsearch\src\Elasticsearch\Namespaces\IndicesNamespace.php 的第600行   public function putMapping($params)     {         $index = $this->extractArgument($params, 'index');
        $type = $this->extractArgument($params, 'type');
        $body = $this->extractArgument($params, 'body');
        /** @var callback $endpointBuilder */         $endpointBuilder = $this->endpoints;
        /** @var \Elasticsearch\Endpoints\Indices\Mapping\Put $endpoint */         $endpoint = $endpointBuilder('Indices\Mapping\Put');         $endpoint->setIndex($index)                  ->setType($type)                  ->setBody($body);         $endpoint->setParams($params);
        return $this->performRequest($endpoint);     }       源码要求必须带有type,所以就报错了。行叭,按照错误提示,需要加的这个参数,ES-PHP貌似也识别不了,所以有关mapping的一些操作就只能等待版本的更新了。
2、解决方案
博主在github上面提交了一条issues,有大佬指点了一条道路:
     $params = [             'index' => 'user',                 'custom' => [                     'include_type_name' => true             ],             'type'=>'_doc',             'body' => [             'properties' => [ ] ] $response = $client->indices()->putMapping();
print_r($response); 通过传参解决的,这边的传参要遵循固定的格式,下面为参考链接: 官方文档: https://github.com/elastic/elasticsearch-php/blob/master/docs/per-request-configuration.asciidoc#providing-custom-query-parameters issues: https://github.com/elastic/elasticsearch-php/issues/883  
戴国进
关注
关注
点赞
收藏
评论
使用elasticsearch-php需要注意的match_all和mapping问题
一、前言最近在把ELK升级到7.0之后,发现使用的ES-PHP并不兼容7.0的版本,可能作者正在努力开发新版本中吧。不过身为使用者,目前还是尽量少用7.0的一些新特性吧,兼容旧版本的ES还是可以的。二、问题1、使用match_all报错(1)报错信息:{"error":{"root_cause":[{"type":"parsing_exception","reason":"[match_all] query malformed, no start_object after q...
复制链接
扫一扫
专栏目录
Elasticsearch-PHP 搜索操作
三丰的专栏
11-09
1万+
搜索操作
好吧,这不叫elasticsearch的不劳而获!让我们来谈谈PHP客户端中的搜索操作。
客户端允许你通过REST API访问所有的查询和公开的参数,尽可能的遵循命名规则。让我们来看一些例子,你就可以熟悉它的语法。
匹配查询
这里是一个标准的匹配查询的curl:
curl -XGET 'localhost:9200/my_index/my_type/_search' -d '{
PHP es 高亮显示
最新发布
m0_58861359的博客
10-24
764
es
参与评论
您还未登录,请先
登录
后发表或查看评论
elasticsearch php搜索,ElasticSearch并在PHP中搜索多个字段
weixin_39913141的博客
03-10
345
我使用的是最新版本的elasticsearch-php以及最新版本的MongoDB和ElasticSearch.我需要在可以包含一个或多个值的多个字段上进行搜索.例:country_code应该是NL,BE或DE和类别应包含AA01,BB01,CC02或ZZ11我以为我会按照以下方式解决它(PHP):$countries = array(“NL”, “BE”, “DE”);$category = ...
PHP 操作 Elasticsearch 所遇到的错误
csdn_fan321的博客
12-25
1377
前言
最近公司有用到elasticsearch,碰到了几个问题,记录以下,方便以后查阅
1)使用php操作es遇到的问题…es服务器返回"request body is required"(php5.6以下版本)
问题描述:使用php-elasticsearch操作es的时候出现request body is required错误
问题位置:vendor\elasticsearch\elastic...
ElasticSearch-PHP踩过的坑
lookingatsky的博客
08-30
194
本人使用的ElasticSearch7.3
官方文档坑得要命
好多demo拿下来根本没法用
每个demo创建完索引(index)再创建文档模板(mapping)的时候都报错
这边网上查到的资料有的说因为ElasticSearch移除了type
需要添加 ‘include_type_name’ => true
经测试,纯属扯淡!!!
通过排查log日志发现,log中报“No handler for type [string] declared on field [profile]”的错误
最后再查阅
Elasticsearch出现circuit_breaking_exception异常
weixin_38232096的博客
12-02
2593
异常
"error" : {
"root_cause" : [
"type" : "circuit_breaking_exception",
"reason" : "[parent] Data too large, data for [<http_request>] would be [115813528/110.4mb], which is larger than the limit of [115553075/110.1mb],
es multi match_PHP 的ES搜索操作
weixin_39542514的博客
11-23
123
原文:https://blog.csdn.net/JineD/article/details/106650695首先从ES的支持的字段说起,ES文档中字段有多种类型 官方文档。这几个比较常用:text,keyword,integer,float,boolean,object,geo_point(地理坐标),geo_shape(描述地理区域),date.注:不要以为date只能表示 20...
PHP 的ES搜索操作
JineD的博客
06-09
1万+
首先从ES的支持的字段说起,ES文档中字段有多种类型官方文档。
这几个比较常用:
text,keyword,integer,float,boolean,object,geo_point(地理坐标),geo_shape(描述地理区域),date.
注:不要以为date只能表示 2015-01-01 这种类型,2015/01/01 12:10:30这种类型也一样可以,不像MySQL里面时间还分很多种细分的类型,ES就一个date类型。
注意:这里没有列出array,在ES中,array不是一种单独的类.
ElasticSearch学习笔记 | Match_ALL进阶检索
北鹤M的代码手账
01-27
7178
一、导入测试数据
ElasticSearch官方为我们准备了一部分测试数据供调试使用,我们可以在安装完成Kinaba后进行数据导入处理
1. 获取数据
打开https://github.com/elastic/elasticsearch/blob/master/docs/src/test/resources/accounts.json
复制全部数据(点击 Raw 按钮,新页面 Ctrl + A)
2. 执行批量添加
打开 Kinaba :xxxx:5601/app/dev_tools#/co..
ElasticSearch 查询 matchAll使用方法
酆都城博客
08-28
1280
ElasticSearch 查询
matchAll 查询脚本:就是查询所有文档
语法:
GET 索引名称/_search
“query”:{
“match_all”:{
},
// 设置分页参数
“from”:0,
“size”:100
}}
matchAll-JavaAPI**
java代码操作 matchAll 查询全部 进行分页控制
/**
* 查询所有
* 1. matchAll
* 2. 将查询结果封装为Goods对象,装载到List中
* 3
★ElasticSearch05高级搜索--matchAll--term查询--★match全文检索(常用)
Strong_shady的博客
08-24
181
一。matchAll
注:只有ES发Get请求把请求放在请求体里
1.2搜索并分页:
ES默认只返回十条数据,但是可以手动设置显示多少条
GET /goods/_search
"query": {
"match_all": {}
},
"from": 0, //从第一条查
"size": 11 //查11条
1.2搜索分页–javaAPI
@Test
public void testMatchAllByPage() throws IOException {
//
ElasticSearch 匹配查询(match、match_phrase)
鲨鱼辣椒的博客
08-31
3052
ElasticSearch 匹配查询(match、match_phrase)
match查询属于全文查询,在查询时,ES会先分析查询字符串,然后根据分词构建查询。
match_phrase在查询时也会先分析查询字符串,然后对这些词项进行搜索,不同的是match_phrase查询只会保留包含全部查询字符串的文档
1、先向ES查询俩个文档,以便测试:
PUT test2/_doc/1
"name": "宝马法拉利兰博基尼"
PUT test2/_doc/2
"name": "宝马兰博基尼布
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST
热门推荐
qq_33286695的博客
12-13
2万+
错误如下:
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request [/idx]","header":{"WWW-Authenticate":"Basic realm=\&quo
{“error“:{“root_cause“:[{“type“:“invalid_index_name_exception“,“reason“:“Invalid index name [Chen_in
weixin_45521812的博客
06-11
1075
详细报错信息
Warnings: [[types removal] Using include_type_name in create index requests is deprecated. The parameter will be removed in the next major version.]
{"error":{"root_cause":[{"type":"invalid_index_name_exception","reason":"Invalid index name [Chen_in
ElasticSuite 堆内存不足报错 “error“: {“root_cause“: [{ “type“: “circuit_breaking_excep
CyrusZhou的专栏
02-23
1119
目录
错误提示:
问题原因
解决办法:
可能遇到的错误:
错误提示:
"error": {
"root_cause": [
"type": "circuit_breaking_exception",
"reason": "[parent] Data too large, data for [<http_request>] would be [1050823878/
PHP-elasticsearch配置+基于elasticsearch全文搜索引擎的开发小结
YEE_HOLIC的博客
09-04
2437
首先参照官网内容下载与自己php以及elasticsearch版本相匹配的Php-elasticsearch,按照官网内容进行配置https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html
接下来讲一下我基于elasticsearch-PHP开发的一个全文搜索项目
说明一下:PHP使用...
php-elasticsearch 设置mapping
weixin_38617363的博客
02-22
1255
一,属性了解
Mapping中字段类型一旦设定后,禁止直接修改(Lucene实现的倒排索引生成后不允许修改)
重新建立新的索引,然后做reindex操作
允许新增字段
通过dynamic参数来控制字段的新增
true:默认值,允许自动新增字段
false:不允许自动新增字段,但是文档可以正常写入,但无法对字段进行查询等操作
strict:文档不能写入,报错
二,不用phpelastic...
【ElasticSearch(五)进阶】两种_search检索方式,match_all检索,Query DSL基本使用...
u012161251的博客
08-24
316
【ElasticSearch(五)进阶】两种_search检索方式,match_all检索,Query DSL基本使用
一、导入测试数据
ElasticSearch官方为我们准备了一部分测试数据供调试使用,我们可以Kinaba内进行数据导入处理
1.获取数据https://download.elastic.co/demos/kibana/gettingstarted/accounts.zip
2...
【ES从入门到实战】十、全文检索-ElasticSearch-进阶-QueryDSL基本使用&match_all
runewbie的博客
05-25
1075
接第9节
2、Query DSL
在上一节中使用的形如
GET /bank/_search
"query": {
"match_all": {}
},
"sort": [
"account_number": "asc"
},
"balance": "desc"
的查询语言风格,我们称之为 Query DSL。
1)、基本语法格式
Elastisearch 提供了一个可以执行查询的 Json 风格.
ElasticSearch查询DSL之全文检索(match_all、match、match_phrase、match_phrase_prefix、multi_match)
阿星的博客
01-13
2426
介绍ES中的全文检索方法,包括match_all、match、match_phrase、match_phrase_prefix、multi_match等几种DSL的详细介绍。以及minimum_should_match、fuzziness、best_fields、most_fields、cross_fields等参数的详细介绍。
Elasticsearch(六) java代码操作Es进行高级查询match、match_all
liuhenghui5201的专栏
06-01
3693
Es在查询时其主要步骤如下:
1,构建SearchRequest请求对象,指定索引库,
2,构建SearchSourceBuilder查询对象
3,构建QueryBuilder对象指定查询方式和查询条件
4,将QuseryBuilder对象设置到SearchSourceBuilder对象中
5,将SearchSourceBuilder设置到SearchRequest中
6,调用方法查询数据
7,解析返回结果
代码如下:
package com.xiaohui;
import org.apach
“相关推荐”对你有帮助么?
非常没帮助
没帮助
一般
有帮助
非常有帮助
提交
©️2022 CSDN
皮肤主题:代码科技
设计师:Amelia_0503
返回首页
戴国进
CSDN认证博客专家
CSDN认证企业博客
码龄12年
深圳万兴科技
512
原创
936
周排名
406
总排名
448万+
访问
等级
2万+
积分
1万+
粉丝
487
获赞
154
评论
1906
收藏
私信
关注
热门文章
完美解决 Could not find a version that satisfies the requirement 安装包名字 (from versions: )
113622
配置MacVim,高亮+自动缩进+行号+折叠+优化
68834
通俗讲解 同步、异步、阻塞、非阻塞 编程
67754
三次握手,四次挥手,为什么是三次握手四次挥手
67519
gitlab-ci.yml 项目实战
65648
分类专栏
docker
付费
46篇
goLang
付费
73篇
php
付费
48篇
php笔试 | 面试题
付费
28篇
算法 / 数据结构
付费
15篇
goLang 笔试 | 面试题
8篇
Gin | iris
9篇
php拓展 | composer
16篇
Laravel
33篇
swoole | swoft
27篇
phpstorm | 单元测试
7篇
正则表达式
11篇
ffmpeg | mencoder
26篇
mysql | tidb
34篇
11篇
优化
12篇
redis | Lua
21篇
nginx
25篇
架构 | 设计模式
16篇
linux
36篇
shell脚本
13篇
ssh | rsync | nfs
16篇
vim | supervisor
9篇
服务安装
10篇
网络IO | 计算机原理
7篇
k8s | docker swarm
15篇
python
13篇
爬虫 | 机器学习
6篇
mongodb
12篇
javascript | html
7篇
jquery | TypeScript | RxJS
3篇
vue学习专栏
11篇
zabbix | prometheus
8篇
ElasticSearch
31篇
logstash | filebeat | kibana
16篇
RabbitMq
9篇
kafka | zookeeper
10篇
jenkins
10篇
git | gitlab
17篇
java
2篇
postman | jmeter
7篇
Fiddler | Vagrant | Autohotkey
15篇
mac | windows 使用技巧
9篇
最新评论
centos7 yum的卸载与安装
明想:
https://blog.csdn.net/weixin_45124488/article/details/105183699
完美解决 Could not find a version that satisfies the requirement 安装包名字 (from versions: )
#Crazydone:
Could not find a version that satisfies the requirement uWSGI==2.0.18 (from versions: 1.4.9, 1.4.10, 1.9, 1.9.1, 1.9.2, 1.9.3,
1.9.4, 1.9.5, 1.9.6, 1.9.7, 1.9.8, 1.9.9, 1.9.10, 1.9.11, 1.9.12, 1.9.13, 1.9.14, 1.9.15, 1.9.16, 1.9.17, 1.9.17.1, 1.9.18, 1.9.18.1
, 1.9.18.2, 1.9.19, 1.9.20, 1.9.21, 1.9.21.1, 2.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.5.1, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.0.10, 2.
0.11, 2.0.11.1, 2.0.11.2, 2.0.12, 2.0.13, 2.0.13.1, 2.0.14, 2.0.15, 2.0.16, 2.0.17, 2.0.17.1, 2.0.18, 2.0.19, 2.0.19.1, 2.0.20, 2.0.2
1)
完美解决 Could not find a version that satisfies the requirement 安装包名字 (from versions: )
LLcattttttt:
我的也是查询pip支持哪些符号的时候,提示模块没有'pep425tags'的描述。请问博主还能怎么查询啊?
完美解决 Could not find a version that satisfies the requirement 安装包名字 (from versions: )
@止于至善:
ERROR: Could not find a version that satisfies the requirement flask-sqlachemy (from versions: none)
ERROR: No matching distribution found for flask-sqlachemy
这个咋办呢pip已经不能升级了
完美解决 Could not find a version that satisfies the requirement 安装包名字 (from versions: )
Helen_0726:
求问在colab中报这样的错怎么解决啊
您愿意向朋友推荐“博客详情页”吗?
强烈不推荐
不推荐
一般般
推荐
强烈推荐
提交
最新文章
Ubuntu 编译安装支持 nvidia gpu 驱动的 FFMPEG
FFmpeg 使用 Nvidia GPU 进行转码加速
使用 OpenTelemetry 零代码修改接收 SkyWalking 追踪数据
2022
12月
5篇
11月
5篇
10月
11篇
09月
7篇
08月
14篇
07月
17篇
06月
20篇
05月
18篇
04月
13篇
03月
10篇
02月
7篇
01月
1篇
2021年218篇
2020年394篇
2016年4篇
2015年5篇
目录
目录
分类专栏
docker
付费
46篇
goLang
付费
73篇
php
付费
48篇
php笔试 | 面试题
付费
28篇
算法 / 数据结构
付费
15篇
goLang 笔试 | 面试题
8篇
Gin | iris
9篇
php拓展 | composer
16篇
Laravel
33篇
swoole | swoft
27篇
phpstorm | 单元测试
7篇
正则表达式
11篇
ffmpeg | mencoder
26篇
mysql | tidb
34篇
11篇
优化
12篇
redis | Lua
21篇
nginx
25篇
架构 | 设计模式
16篇
linux
36篇
shell脚本
13篇
ssh | rsync | nfs
16篇
vim | supervisor
9篇
服务安装
10篇
网络IO | 计算机原理
7篇
k8s | docker swarm
15篇
python
13篇
爬虫 | 机器学习
6篇
mongodb
12篇
javascript | html
7篇
jquery | TypeScript | RxJS
3篇
vue学习专栏
11篇
zabbix | prometheus
8篇
ElasticSearch
31篇
logstash | filebeat | kibana
16篇
RabbitMq
9篇
kafka | zookeeper
10篇
jenkins
10篇
git | gitlab
17篇
java
2篇
postman | jmeter
7篇
Fiddler | Vagrant | Autohotkey
15篇
mac | windows 使用技巧
9篇
目录
评论
被折叠的 条评论
为什么被折叠?
到【灌水乐园】发言
查看更多评论
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额
抵扣说明:
1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。 2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。
余额充值