Elasticsearch percolate mapping error - elasticsearch

I want to use percolate query in elasticsearch. But I couldn't setup mapping. I have received the following error. where is my fault?
PUT /my-index
{
"mappings": {
"doctype": {
"properties": {
"message": {
"type": "string"
}
}
},
"queries": {
"properties": {
"query": {
"type": "percolator"
}
}
}
}
}
Error Message:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "No handler for type [percolator] declared on field [query]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [queries]: No handler for type [percolator] declared on field [query]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "No handler for type [percolator] declared on field [query]"
}
},
"status": 400
}
Thanks

Related

ElasticSearch - Cant not sort by distance location - "status": 500

Target: search people and sort their name by the distance from their location to my location (input lat lon)
I input many rows of data like this :
{"index":{"_id":"1"}}
{"account_number":1,"location":[22.23, 23.12],"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke#pyrami.com","city":"Brogan","state":"IL"}
Notice the location here I input "location":[22.23, 23.12]
For simplicity, the below is the mapping of firstname, lastname and location
{
"lat_lon_test2": {
"mappings": {
"properties": {
"firstname": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"lastname": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"location": {
"type": "float"
},
..........................................
This my trial:
GET localhost:9200/lat_lon_test2/_search?pretty
{
"query":
{
"multi_match":
{
"fields":["firstname", "lastname"],
"minimum_should_match": "80%",
"query": "Hattie"
}
}
,
"sort": [
{
"_geo_distance": {
"location": [
40.715,
-73.998 //my input location
],
"order": "asc",
"unit": "km",
"distance_type": "plane"
}
}
]
}
I got this result :
{
"error": {
"root_cause": [
{
"type": "class_cast_exception",
"reason": "class org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData cannot be cast to class org.elasticsearch.index.fielddata.IndexGeoPointFieldData (org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData and org.elasticsearch.index.fielddata.IndexGeoPointFieldData are in unnamed module of loader 'app')"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "lat_lon_test2",
"node": "oyC0x3WNRC-3ok_TzAMT2w",
"reason": {
"type": "class_cast_exception",
"reason": "class org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData cannot be cast to class org.elasticsearch.index.fielddata.IndexGeoPointFieldData (org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData and org.elasticsearch.index.fielddata.IndexGeoPointFieldData are in unnamed module of loader 'app')"
}
}
],
"caused_by": {
"type": "class_cast_exception",
"reason": "class org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData cannot be cast to class org.elasticsearch.index.fielddata.IndexGeoPointFieldData (org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData and org.elasticsearch.index.fielddata.IndexGeoPointFieldData are in unnamed module of loader 'app')",
"caused_by": {
"type": "class_cast_exception",
"reason": "class org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData cannot be cast to class org.elasticsearch.index.fielddata.IndexGeoPointFieldData (org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData and org.elasticsearch.index.fielddata.IndexGeoPointFieldData are in unnamed module of loader 'app')"
}
}
},
"status": 500
}
I realise that I need to mapping location to geopoint
I did this:
PUT localhost:9200/lat_lon_test2/_mapping
{
"properties": {
"location": {
"type": "geo_point"
}
}
}
I got this result:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "mapper [location] cannot be changed from type [float] to [geo_point]"
}
],
"type": "illegal_argument_exception",
"reason": "mapper [location] cannot be changed from type [float] to [geo_point]"
},
"status": 400
}
My version: 7.9.3
Sorry for long post
You are changing the data-type of location from float to geo_point which is not possible, hence the exception, please create a new index with proper mapping and reindex all data according to the new data-type to fix the issue.
Please refer to the section on update mapping of a field and what is covered and what is not covered, Also If you need to change the mapping of a field in other indices, create a new index with the correct mapping and reindex your data into that index.

elasticsearch mapping issue: failed to parse field

I have this mapping
PUT /mytest
{
"mappings":{
"properties": {
"value": { "type": "object" }
}
}
}
When I insert this document
POST /mytest/_doc/4
{
"value": { "value": "test"}
}
I got the following error:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse field [value.value] of type [long] in document with id '4'. Preview of field's value: 'test'"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse field [value.value] of type [long] in document with id '4'. Preview of field's value: 'test'",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "For input string: \"test\""
}
},
"status": 400
}
I know the naming convention is bad, still, this is a valid JSON request, not sure why it doesn't allow it.
This error is telling you that you don't have a mapping for the property value within your value object property. The below example would property set the value.value property within your mytest index:
PUT mytest
{
"mappings": {
"properties": {
"value": {
"type": "object",
"properties": {
"value": {
"type": "text"
}
}
}
}
}
}
However, I don't think that's what your intention was. As a best practice, try following the Elastic Common Schema (ECS) for naming your index properties.

Update a particular field in ES 2.4.0 document?

I have document like this
"College": "UCLA",
"University": "American",
"Branch": "MECH",
"Name": {
"first": "john",
"middle": "william",
"last": "Richards"
}
I have to update the last field in Name group
I tried with the following but it is showing error
POST alma/matter/1/_update
{
"doc": { "Name.last": "junior" }
}
Error:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Field name [Name.last] cannot contain '.'"
}
],
"type": "mapper_parsing_exception",
"reason": "Field name [Name.last] cannot contain '.'"
},
"status": 400
}
You're not allowed to reference fields with dots in them. You can do it like this instead:
POST alma/matter/1/_update
{
"doc": { "Name": {"last": "junior" }}
}

failed to parse timestamp elasticsearch

I'm new to elasticsearch and am trying to create my first index but am having issues with a timestamp field that was working before...
I created my index like this:
PUT /kafkasdp
{
"mappings": {
"kafka_logs": {
"properties": {
"timestamp": {
"type": "date"
},
"log_level": {
"type": "string"
},
"message1": {
"type": "string"
},
"message2": {
"type": "string"
}
}
}
}
}
and then I'm trying to send data like this:
post /kafkasdp/kafka_logs
{
"timestamp": "2017-02-03 19:27:20,606",
"log_level": "INFO",
"message2": "Deleting segment 1 from log omega-replica-sync-dev-8. (kafka.log.Log)"
}
but keep getting this error:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse [timestamp]"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse [timestamp]",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Invalid format: \"2017-02-03 19:27:20,606\" is malformed at \" 19:27:20,606\""
}
},
"status": 400
}
I thought my timestamp is a valid date type?
Read about date type on Elasticsearch reference: you should specify format of date you are expecting in your documents:
PUT your_index_name
{
"mappings": {
"your_index_type": {
"properties": {
"date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss,SSS"
}
}
}
}
}
As you did not specify it, Elasticsearch will expect date value in ISO format:
yyyyMMdd'T'HHmmss.SSS'Z' (e.g., 2017-02-03T19:27:20.606Z)

Can not create Elasticsearch Index (logstash-2015.05.18)

I'm using Elasticsearch 2.4
Following the instruction from the Elasticsearch Kibana official documentation here, when I create the index logstash-2015.05.18, the error below were emitted.
# curl -XPUT http://10.15.0.70:9200/logstash-2015.05.18 -d '
{
"mappings": {
"log": {
"properties": {
"geo": {
"properties": {
"coordinates": {
"type": "geo_point"
}
}
}
}
}
}
}
';
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [“store” : true]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [“date”]: Root mapping definition has unsupported parameters: [“store” : true]","caused_by":{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [“store” : true]"}},"status":400}
Using the sense plugin of Kibana to create the index also gives me the same error
PUT logstash-2015.05.18
{
"mappings": {
"log": {
"properties": {
"geo": {
"properties": {
"coordinates": {
"type": "geo_point"
}
}
}
}
}
}
}
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [“store” : true]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [“date”]: Root mapping definition has unsupported parameters: [“store” : true]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [“store” : true]"
}
},
"status": 400
}
Can someone tell me did I do something wrong when creating the index?
Had same trouble.
Removing elasticsearch data("/usr/local/var/elasticsearch", if you install it with Homebrew) fixed it for me.

Resources