-
-
Save alexbrasetvik/3e5fcb1b4c41cfc20226 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text: | |
- SVF-123 | |
- SVF-234 | |
analyzer: | |
analyzer_keyword: | |
type: custom | |
tokenizer: keyword | |
filter: | |
- lowercase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "SVF-123" | |
--- | |
name: "SVF-234" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type: | |
# Your query_string query ends up as an OR on "*svf" and "1*". | |
# _all: | |
# enabled: false | |
properties: | |
name: | |
type: string | |
# This is problematic. Terms are not being analyzed index time, | |
# but is search time. And the search time analyzer generates incompatible terms. | |
index: not_analyzed | |
analyzer: analyzer_keyword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export ELASTICSEARCH_ENDPOINT="http://localhost:9200" | |
# Create indexes | |
curl -XPUT "$ELASTICSEARCH_ENDPOINT/play" -d '{ | |
"settings": { | |
"analysis": { | |
"text": [ | |
"SVF-123", | |
"SVF-234" | |
], | |
"analyzer": { | |
"analyzer_keyword": { | |
"type": "custom", | |
"tokenizer": "keyword", | |
"filter": [ | |
"lowercase" | |
] | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"type": { | |
"properties": { | |
"name": { | |
"type": "string", | |
"index": "not_analyzed", | |
"analyzer": "analyzer_keyword" | |
} | |
} | |
} | |
} | |
}' | |
# Index documents | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_bulk?refresh=true" -d ' | |
{"index":{"_index":"play","_type":"type"}} | |
{"name":"SVF-123"} | |
{"index":{"_index":"play","_type":"type"}} | |
{"name":"SVF-234"} | |
' | |
# Do searches | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d ' | |
{ | |
"facets": { | |
"name": { | |
"terms": { | |
"field": "name" | |
} | |
}, | |
"_all": { | |
"terms": { | |
"field": "_all" | |
} | |
} | |
} | |
} | |
' | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d ' | |
{ | |
"query": { | |
"match": { | |
"name": { | |
"query": "SVF-123" | |
} | |
} | |
} | |
} | |
' | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d ' | |
{ | |
"query": { | |
"term": { | |
"name": { | |
"value": "SVF-123" | |
} | |
} | |
} | |
} | |
' | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d ' | |
{ | |
"query": { | |
"term": { | |
"_all": { | |
"value": "svf" | |
} | |
} | |
} | |
} | |
' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Auto generated by Found's Play-tool at 2014-01-16T15:12:43+01:00 | |
version: 0 | |
title: "Erroneous analysis configuration " | |
description: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In reply to http://stackoverflow.com/questions/21161062/elasticsearch-wildcard-search-on-not-analyzed-field | |
# See all the generated terms. | |
facets: | |
name: | |
terms: | |
field: name | |
_all: | |
terms: | |
field: _all | |
--- | |
query: | |
match: | |
name: | |
# Analyzed, so no match | |
query: "SVF-123" | |
--- | |
query: | |
term: | |
name: | |
# Not analyzed according to `analyzer_keyword`, so matches. | |
value: "SVF-123" | |
--- | |
query: | |
term: | |
_all: | |
value: svf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment