spring-data-elasticsearch使用出现的一些小问题
问题一
failed to load elasticsearch nodes : org.elasticsearch.index.mapper.MapperParsingException: No type specified for field【属性名称]
出现这个问题,我就想到了用solr时需要再solr的配置文件中配置自己的字段,难道是因为我没有配置?最后看了许多文章,自己又测试了许久,并不是,但又有一点关系!
解决:
1、查看是否在对应的pojo中写上了@Document(indexName = “test”,type = “article”)
即indexName,与type不能缺少,如下
@Document(indexName = "test",type = "article")
public class Article implements Serializable {
2、在pojo的实体类属性把@Field去掉,如下(关于为什么去掉,和我有需求必须要加上该属性,比如该字段我需要分词,必须配置,看第3种方法)
/* @Field(index = true,analyzer="ik_max_word",searchAnalyzer="ik_max_word") */
private String content;
3、必须需要@Field属性,因为某些字段需要分词,在@field属性中再加上一个字段(type ),表明自己定义的该字段对应elasticsearch已近定义好的字段类型(出现该错误主要是由于该问题),如下
@Field(index = true,type = FieldType.text,analyzer="ik_max_word",searchAnalyzer="ik_max_word")
private String content;
对于其它的java类型,使用枚举FieldType中的属性一一对应即可,源码如下:
public enum FieldType {
text,
Integer,
Long,
Date,
Float,
Double,
Boolean,
Object,
Auto,
Nested,
Ip,
Attachment,
keyword;
private FieldType() {
}
}
问题二
Unsupported Media Type 415
吐槽:
说实话这个问题我真是没想到(因为之前都用的好好的。。)
原因:因为Content-type格式不正确,我后台接收用的是json接收,我这里是用的Google插件种的 postman,发送的时候用的是json格式数据,但是这个插件发送json的content-type不是palnt/text,而不是application/json
解决
更改content-type的格式为application/json
原文:https://blog.csdn.net/qq_38263083/article/details/86625218
spring-data-elasticsearch使用出现的一些小问题的更多相关文章
- ElasticSearch(十二):Spring Data ElasticSearch 的使用(二)
在前一篇博文中,创建了Spring Data Elasticsearch工程,并且进行了简单的测试,此处对Spring Data Elasticsearch进行增删改查的操作. 1.增加 在之前工程的 ...
- Spring Data Elasticsearch 用户指南
https://www.jianshu.com/p/27e1d583aafb 翻译自官方文档英文版,有删减. BioMed Central Development Team version 2.1.3 ...
- elasticsearch系列七:ES Java客户端-Elasticsearch Java client(ES Client 简介、Java REST Client、Java Client、Spring Data Elasticsearch)
一.ES Client 简介 1. ES是一个服务,采用C/S结构 2. 回顾 ES的架构 3. ES支持的客户端连接方式 3.1 REST API ,端口 9200 这种连接方式对应于架构图中的RE ...
- Elasticsearch基本用法(2)--Spring Data Elasticsearch
Spring Data Elasticsearch是Spring Data项目下的一个子模块. 查看 Spring Data的官网:http://projects.spring.io/spring-d ...
- Elasticsearch Java client(ES Client 简介、Java REST Client、Java Client、Spring Data Elasticsearch)
elasticsearch系列七:ES Java客户端-Elasticsearch Java client(ES Client 简介.Java REST Client.Java Client.Spri ...
- spring data elasticsearch 使用
很久之前就安装了elasticsearch,一直没用java用过,最近看了一下spring data系列的elasticsearch,这里写一篇心得. 如果尚未安装elasticsearch,可以 参 ...
- Spring Boot + Spring Data + Elasticsearch实例
Spring Boot + Spring Data + Elasticsearch实例 学习了:https://blog.csdn.net/huangshulang1234/article/detai ...
- elasticsearch 拼音+ik分词,spring data elasticsearch 拼音分词
elasticsearch 自定义分词器 安装拼音分词器.ik分词器 拼音分词器: https://github.com/medcl/elasticsearch-analysis-pinyin/rel ...
- How to provide highlighting with Spring data elasticsearch
How to provide highlighting with Spring data elasticsearch @Test public void shouldReturnHighlighted ...
- springboot集成spring data ElasticSearch
ES支持SpringBoot使用类似于Spring Data Jpa的方式查询,使得查询更加方便. 1.依赖引入 compile “org.springframework.boot:spring-bo ...
随机推荐
- uwsgi支持http长链接
http1.1支持长链接,而http1.0不支持,所以,在切换http版本号或者升级服务端版本时候,尤其要注意这个造成的影响. 当客户端以http1.1长链接方式连接服务端时,服务端如果不支持1.1, ...
- if_else
//if.......else if......else //object IF_ELSE {// def main(args:Array[String]){// var x=30// if (x== ...
- puppet使用rsync模块
puppet使用rsync模块同步目录和文件 环境说明: OS : CentOS5.4 i686puppet版本: ...
- synchronized 与 lock 的区别
synchronized 和 lock 的用法区别 synchronized(隐式锁):在需要同步的对象中加入此控制,synchronized 可以加在方法上,也可以加在特定代码块中,括号中表示需要锁 ...
- 微信小程序 上拉刷新/下拉加载
小程序项目中上拉刷新下拉加载是比较常见的需求,官方文档也提供了相当友好的API,但是因为API隐藏的比较深,文档描述也比较模糊所以也折腾了一番(官方文档),在此记录一下使用方式 onPullDownR ...
- Comet OJ - Contest #4 D求和 思维题
Code: #include <bits/stdc++.h> #define setIO(s) freopen(s".in","r",stdin) ...
- 【bzoj4137】[FJOI2015]火星商店问题
*题目描述: 火星上的一条商业街里按照商店的编号1,2 ,…,n ,依次排列着n个商店.商店里出售的琳琅满目的商品中,每种商品都用一个非负整数val来标价.每个商店每天都有可能进一些新商品,其标价可能 ...
- 【bzoj3998】[TJOI2015]弦论
题目描述: 对于一个给定长度为N的字符串,求它的第K小子串是什么. 样例输入: aabc 0 3 样例输出: aab 题解: 构造后缀自动机,然后在后缀自动机上跑dfs 代码: #include &l ...
- formdata方式上传文件,支持大文件分割上传
1.upload.html <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/html"> <h ...
- SpringBoot项目的前端+thymeleaf模板引擎
SpringBoot项目创建之后,后台的框架是SpringMVC.但前端的resource和template目录都是空的.这个时候需要创建前台页面. 习惯上,我们会创建JSP,但是,SpringBoo ...