Tag Archives: Search Engines

[Windows] elasticsearch.exceptions.RequestError: <unprintable RequestError object>

elasticsearch.exceptions.RequestError: <unprintable RequestError object>

There are many ways to solve this problem.
Use the following two commands in Pycharm
$pip install django haystack
$pip install elasticsearch==2.4.1

Note that the server-side elasticsearch should be consistent with the pip install elasticsearch==2.4.1 version

How to Solve elasticsearch and logstash Install Error

Turning on the logstash service appears: Failed to start logstash.service: Unit not found.

[root@localhost ~]# systemctl start logstash
Failed to start logstash.service: Unit not found.

Issue 1:
First problem: Failed to start logstash.service: Unit not found.
Solution idea.
Generate logstash.service file

[root@localhost ~]# sudo /usr/share/logstash/bin/system-install /etc/logstash/startup.options systemd

Check if the service can be opened normally

Issue 2:
The second problem: If you use this access could not find any executable java binary. Please install java in your PATH or set JAVA_HOME.

[root@localhost ~]# sudo /usr/share/logstash/bin/system-install /etc/logstash/startup.options systemd
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME.

Reason: logstash can’t get to AVA_HOME variable, need to add refresh profile in the configuration file
Solution.

[root@localhost ~]# vi /etc/profile                #Add the specified version of the JDK directory installed on the local machine
export JAVA_HOME=/usr/local/jdk1.8
export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/lib:$JAVA_HOME/jre/bin:$PATH:$HOME/bin

[root@localhost ~]# vi /usr/share/logstash/bin/logstash.lib.sh
Add source /etc/profile in the last line
[root@localhost ~]# vi /usr/share/logstash/bin/logstash
Add source /etc/profile in the last line

Refresh the configuration file, and then see if the service can be opened normally

Issue 3:
Third problem : /usr/share/logstash/vendor/jruby/bin/jruby:line 388: /usr/bin/java: No that file or directory
Unable to install system startup script for Logstash.
Reason: Can’t get the java executable file
Solution:

[root@localhost ~]# ln -s /usr/local/jdk1.8/bin/java /usr/bin/java

Reinstall the service to install.

[root@localhost ~]# rpm -e logstash
Error: package logstash is not installed
[root@localhost ~]# rpm -ivh /mnt/logstash-5.5.1.rpm
Warning: /mnt/logstash-5.5.1.rpm: Head V4 RSA/SHA512 Signature, key ID d88e42b4: NOKEY
In preparation…                          ################################# [100%]
Package logstash-1:5.5.1-1.noarch is installed

Generate logstash.service file

[root@localhost ~]# sudo /usr/share/logstash/bin/system-install /etc/logstash/startup.options systemd
Using provided startup.options file: /etc/logstash/startup.options

Start successfully!

[root@localhost ~]# systemctl start logstash

ES Startup error: ERROR: [2] bootstrap checks failed

ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low,   increase to at least [65536]

Reason: Generally, you can check whether the following nodes are present in the elastic.yaml configuration file in the es installation directory

elsearch soft nofile 65536
elsearch hard nofile 65536

If not, then you need to configure it, and replace the elsearch with your own server user.

There is also a possibility that the above error is still reported even though the server has been configured, possibly due to the fact that the current logged-in user has not synchronized the configuration due to a server reboot.
Use su ~ xx to re-login to solve the problem.

[Solved] ElasticsearchStatusException[Elasticsearch exception [type=mapper_parsing_exception, reason=failed t

Project scenario:

Today, when I was writing code in Java to check the data in ES, the following error occurred. I checked it for a while and found the problem


Console prompt

ElasticsearchStatusException[Elasticsearch exception [type=mapper_parsing_exception, reason=failed to parse field [location] of type [geo_point]]
]; nested: ElasticsearchException[Elasticsearch exception [type=parse_exception, reason=unsupported symbol [.] in geohash [30.871729121.81959]]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=unsupported symbol [.] in geohash [30.871729121.81959]]];
	at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:176)
	at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:2011)
	at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1988)
	at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1745)
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1702)
	at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1672)
	at org.elasticsearch.client.RestHighLevelClient.index(RestHighLevelClient.java:1029)
	at com.woniu.EsDemoApplicationTests.insertDoc(EsDemoApplicationTests.java:115)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at 
	at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
	Suppressed: org.elasticsearch.client.ResponseException: method [PUT], host [http://120.48.46.177:9200], URI [/hotel/_doc/45870?timeout=1m], status line [HTTP/1.1 400 Bad Request]
Warnings: [Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone. See https://www.elastic.co/guide/en/elasticsearch/reference/7.16/security-minimal-setup.html to enable security.]
{"error":{"root_cause":[{"type":"parse_exception","reason":"unsupported symbol [.] in geohash [30.871729121.81959]"}],"type":"mapper_parsing_exception","reason":"failed to parse field [location] of type [geo_point]","caused_by":{"type":"parse_exception","reason":"unsupported symbol [.] in geohash [30.871729121.81959]","caused_by":{"type":"illegal_argument_exception","reason":"unsupported symbol [.] in geohash [30.871729121.81959]"}}},"status":400}
		at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:326)
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:296)
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:270)
		at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2082)
		at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1732)
		... 71 more
Caused by: ElasticsearchException[Elasticsearch exception [type=parse_exception, reason=unsupported symbol [.] in geohash [30.871729121.81959]]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=unsupported symbol [.] in geohash [30.871729121.81959]]];
	at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:485)
	at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:396)
	at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:426)
	at org.elasticsearch.ElasticsearchException.failureFromXContent(ElasticsearchException.java:592)
	at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:168)
	... 74 more
Caused by: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=unsupported symbol [.] in geohash [30.871729121.81959]]]
	at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:485)
	at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:396)
	at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:426)

Cause analysis:

The data structure of the geographic coordinate attribute location in ES is (latitude, longitude), and I inserted a comma in the middle when I spliced strings, resulting in an error in inserting data. Here are the really useful parts of the above code.

Real error reason:

{"error":{"root_cause":[{"type":"parse_exception","reason":"unsupported symbol [.] in 
geohash [30.871729121.81959]"}],"type":"mapper_parsing_exception","reason":"failed to parse 
field [location] of type [geo_point]","caused_by":{"type":"parse_exception","reason":"unsupported symbol [.] in geohash 
[30.871729121.81959]","caused_by":
{"type":"illegal_argument_exception","reason":"unsupported symbol [.] in geohash 
[30.871729121.81959]"}}},"status":400}

Incorrect writing:

this.location = hotel.getLatitude()+hotel.getLongitude();

Correct writing:

this.location = hotel.getLatitude()+","+hotel.getLongitude();

Solution:

Check the string before splicing, and the order (latitude and longitude) cannot be reversed, otherwise it may lead to geographical location errors.

[Solved] ElasticSearch Startup Error: error updating geoip database

Problem Description:

Error when launching elasticsearch:
error updating geoip database

[2021-12-22T21:07:11,944][INFO ][o.e.i.g.GeoIpDownloader  ] [DESKTOP-5JGQJR8] updating geoip database [GeoLite2-ASN.mmdb]
[2021-12-22T21:07:13,022][ERROR][o.e.i.g.GeoIpDownloader  ] [DESKTOP-5JGQJR8] error updating geoip database [GeoLite2-ASN.mmdb]
org.elasticsearch.cluster.block.ClusterBlockException: index [.geoip_databases] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block];

Cause analysis:

This is a bug


Solution:

Add the following configuration to elasticsearch.yml:

ingest.geoip.downloader.enabled: false

Turn off geoip database updates

SpringBoot integrates Es error: Error creating bean with name ‘restHighLevelClient‘ defined in class path resource

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restHighLevelClient' defined in class path resource [com/esdemo/config/ElasticSearchClientConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'restHighLevelClient' threw exception; nested exception is java.lang.NoClassDefFoundError: org/elasticsearch/common/xcontent/DeprecationHandler
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:590)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:330)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
	at com.esdemo.EsdemoApplication.main(EsdemoApplication.java:13)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'restHighLevelClient' threw exception; nested exception is java.lang.NoClassDefFoundError: org/elasticsearch/common/xcontent/DeprecationHandler
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582)
	... 18 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/common/xcontent/DeprecationHandler
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.elasticsearch.client.RestHighLevelClient.<clinit>(RestHighLevelClient.java:1741)
	at com.esdemo.config.ElasticSearchClientConfig.restHighLevelClient(ElasticSearchClientConfig.java:19)
	at com.esdemo.config.ElasticSearchClientConfig$$EnhancerBySpringCGLIB$$cca08d.CGLIB$restHighLevelClient$0(<generated>)
	at com.esdemo.config.ElasticSearchClientConfig$$EnhancerBySpringCGLIB$$cca08d$$FastClassBySpringCGLIB$$14e70886.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
	at com.esdemo.config.ElasticSearchClientConfig$$EnhancerBySpringCGLIB$$cca08d.restHighLevelClient(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 19 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.common.xcontent.DeprecationHandler
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 43 common frames omitted

Process finished with exit code 1

Solution:

Check whether the jar package of ES is introduced into Maven’s POM file

<dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>7.7.0</version>
        </dependency>

If there is still an error after introducing the jar package, add the following to the startup class

 System.setProperty("es.set.netty.runtime.available.processors", "false");