Skip to content

Instantly share code, notes, and snippets.

@matthuhiggins
Created June 24, 2019 18:47
Show Gist options
  • Save matthuhiggins/b5139bfade363744dbad942e2b44f90d to your computer and use it in GitHub Desktop.
Save matthuhiggins/b5139bfade363744dbad942e2b44f90d to your computer and use it in GitHub Desktop.
curl -X DELETE "localhost:9200/companies"
curl -X PUT "localhost:9200/companies" -H 'Content-Type: application/json' -d'
{
"settings": {
"analysis": {
"analyzer": {
"company_name_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["company_name_filter"]
}
},
"filter": {
"company_name_filter": {
"type": "multiplexer",
"filters": [
"company_name_camel_case, lowercase",
"lowercase, company_name_abbreviations"
]
},
"company_name_abbreviations": {
"type": "synonym_graph",
"synonyms": ["co-op => cooperative", "corp,corporation"]
},
"company_name_camel_case": {
"type": "word_delimiter_graph"
}
}
}
},
"mappings": {
"_doc": {
"properties": {
"company_name": {"type": "text", "analyzer": "company_name_analyzer"}
}
}
}
}'
curl -X PUT "localhost:9200/companies/_doc/1" -H 'Content-Type: application/json' -d'
{
"company_name" : "FedEx"
}'
@matthuhiggins
Copy link
Author

matthuhiggins commented Jun 24, 2019

On ES 6.8, this outputs:

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"startOffset must be non-negative, and endOffset must be >= startOffset, and offsets must not go backwards startOffset=0,endOffset=5,lastStartOffset=3 for field 'company_name'"}],"type":"illegal_argument_exception","reason":"startOffset must be non-negative, and endOffset must be >= startOffset, and offsets must not go backwards startOffset=0,endOffset=5,lastStartOffset=3 for field 'company_name'"},"status":400}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment