Elasticsearch showing error 406 when inserting - macos

Just installed ElasticSearch on my mac (brew install elasticsearch).
Then started it with: brew services start elasticsearch.
I can see it is running:
curl localhost:9200
{
"name" : "84ucGje",
"cluster_name" : "elasticsearch_dnk306",
"cluster_uuid" : "yU6wdZpJT_-1OvaFf7l7Ug",
"version" : {
"number" : "6.5.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "816e6f6",
"build_date" : "2018-11-09T18:58:36.352602Z",
"build_snapshot" : false,
"lucene_version" : "7.5.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
When I try to add some index to it - it fails with 406 error:
curl -XPOST localhost:9200/test/1 -d '{"title":"Hello world"}'
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
What do I need to do to make this work?
Thanks.

Related

Problem when running elastic search on windows 10

when i am running elastic search on windows 10 , i can not open elastic portal in the local host and i got this message :
{
"name" : "ISBUS-PC02",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "FE38HTACR2evmiVFD7ciag",
"version" : {
"number" : "8.6.0",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "f67ef2df40237445caa70e2fef79471cc608d70d",
"build_date" : "2023-01-04T09:35:21.782467981Z",
"build_snapshot" : false,
"lucene_version" : "9.4.2",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
nothing, because this is the last issue i stucked on.
This JSON you provided means Elasticsearch is up and running perfectly fine. You can note in the JSON response, Elasticsearch cluster name, version, build type and other information is also provided.
{
"name": "ISBUS-PC02",
"cluster_name": "elasticsearch",
"cluster_uuid": "FE38HTACR2evmiVFD7ciag",
"version":
{
"number": "8.6.0",
"build_flavor": "default",
"build_type": "zip",
"build_hash": "f67ef2df40237445caa70e2fef79471cc608d70d",
"build_date": "2023-01-04T09:35:21.782467981Z",
"build_snapshot": false,
"lucene_version": "9.4.2",
"minimum_wire_compatibility_version": "7.17.0",
"minimum_index_compatibility_version": "7.0.0"
},
"tagline": "You Know, for Search"
}
You don't have to worry, your Elasticsearch cluster is up and running and you can execute other requests.

Elastic search status is running but still getting no reply on curl localhost:9200

I am using elastic search in my laravel project using package elasticquent, I followed this specific tutorial
Laravel Elastic Search
and before that I installed elastic search on my OS(Ubuntu) by following the documentation.
After setting all things I get no reply error after spending some time on error I ran to some solution which says I have to make changes in my elasticsearch.yml file
Changes I made
cluster.name = <my-cluster-name>
node.name = <my-node-name> //basically my System name
I got credentials for above field by the following command
curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic http://localhost:9200
which gives response as follows
{
"name" : "Cp8oag6",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
"version" : {
"number" : "8.4.1",
"build_type" : "tar",
"build_hash" : "f27399d",
"build_flavor" : "default",
"build_date" : "2016-03-30T09:51:41.449Z",
"build_snapshot" : false,
"lucene_version" : "9.3.0",
"minimum_wire_compatibility_version" : "1.2.3",
"minimum_index_compatibility_version" : "1.2.3"
},
"tagline" : "You Know, for Search"
}
so after doing all setup and following the tutorial when I visit my search url I get
No nodes alive and If I try
curl -X GET localhost:9200 It gives no reply error.

Could not validate a connection to Elasticsearch. Unknown 401 error from Elasticsearch null

{
"name" : "DESKTOP-BNTBBBG",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "DlRfjfPlRg69wUBRfy3kKQ",
"version" : {
"number" : "8.1.3",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "39afaa3c0fe7db4869a161985e240bd7182d7a07",
"build_date" : "2022-04-19T08:13:25.444693396Z",
"build_snapshot" : false,
"lucene_version" : "9.0.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
But When running this command
php bin/magento setup:install --base-url="http://versionup.magento.com" --db-host="localhost" --db-name="magento2" --db-user="magento2" --db-password="magento2" --admin-firstname="admin" --admin-lastname="admin" --admin-email="user#example.com" --admin-user="admin" --admin-password="Admin#123456" --language="en_US" --currency="USD" --timezone="America/Chicago" --use-rewrites="1" --backend-frontname="admin" --search-engine=elasticsearch7 --elasticsearch-host="localhost" --elasticsearch-port=9200
Could not validate a connection to Elasticsearch. Unknown 401 error from Elasticsearch null
i have the same problem, but now it's fixed.
make sure you enable xpack.security.http.ssl on elasticsearch.yml. because I disable it before.
then change the host to:
--elasticsearch-host="https://localhost"
then add more options to your command for authentication:
--elasticsearch-enable-auth=true --elasticsearch-username="elastic" --elasticsearch-password="your password"

Basic authentication with hey tool fails

I have an elasticsearch cluster which I can hit as follows:
▶ curl -k https://localhost:9200 -u username:password
{
"name" : "elasticsearch-sample-es-master-1",
"cluster_name" : "elasticsearch-sample",
"cluster_uuid" : "XXXXXXXXXXXXXXXXXXX",
"version" : {
"number" : "7.11.0",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "8ced7813d6f16d2ef30792e2fcde3e755795ee04",
"build_date" : "2021-02-08T22:44:01.320463Z",
"build_snapshot" : false,
"lucene_version" : "8.7.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
(I have port-forwarded the service locally)
However when hitting it with hey
hey https://localhost:9200 -a username:password
Status code distribution:
[401] 200 responses
Any ideas?
You can try the following
hey https://username:password#localhost:9200
That works!
Note: There are open issues in the official hey repository, https://github.com/rakyll/hey/issues/150

X-Pack 401 Logstash cant connect to Elasticsearch

I changed JVM heap sized and Logstash cant connect to Elasticsearch, after restarting Elasticsearch
logstash.yml
xpack.monitoring.enabled: true
xpack.monitoring.elasticsearch.hosts: ["es:9200"]
xpack.monitoring.elasticsearch.username: logstash_system
xpack.monitoring.elasticsearch.password: pass
logs by Logstash
[WARN ][logstash.outputs.elasticsearch][main] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://es:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError, :error=>"Got response code '401' contacting Elasticsearch at URL 'http://es:9200/'"}
curl from logstash to es with same credentials
logstash: curl -ulogstash_system es:9200
Enter host password for user 'logstash_system':
{
"name" : "elasticsearch",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "",
"version" : {
"number" : "7.5.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "",
"build_date" : "2019-11-26T01:06:52.518245Z",
"build_snapshot" : false,
"lucene_version" : "8.3.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

Resources