Skip to content

Instantly share code, notes, and snippets.

@alexbrasetvik
Created November 14, 2013 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexbrasetvik/7464654 to your computer and use it in GitHub Desktop.
Save alexbrasetvik/7464654 to your computer and use it in GitHub Desktop.
Standard tokenization, but without the lowercasing and stopword removal.
text: This text will be used if nothing else is specified.
analyzer:
standard_tokenize_only:
type: custom
tokenizer: standard
# Switch to the "Analysis"-tab to see how the text gets tokenized by default.
standard:
type: standard
title: Foo Bar
---
title: foo bar
type:
properties:
title:
type: string
analyzer: standard_tokenize_only
#!/bin/bash
export ELASTICSEARCH_ENDPOINT="http://localhost:9200"
# Create indexes
curl -XPUT "$ELASTICSEARCH_ENDPOINT/play" -d '{
"settings": {
"analysis": {
"text": "This text will be used if nothing else is specified.",
"analyzer": {
"standard_tokenize_only": {
"type": "custom",
"tokenizer": "standard"
},
"standard": {
"type": "standard"
}
}
}
},
"mappings": {
"type": {
"properties": {
"title": {
"type": "string",
"analyzer": "standard_tokenize_only"
}
}
}
}
}'
# Index documents
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_bulk?refresh=true" -d '
{"index":{"_index":"play","_type":"type"}}
{"title":"Foo Bar"}
{"index":{"_index":"play","_type":"type"}}
{"title":"foo bar"}
'
# Do searches
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d '
{
"query": {
"match": {
"title": {
"query": "Foo"
}
}
}
}
'
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d '
{
"query": {
"match": {
"title": {
"query": "foo"
}
}
}
}
'
# Auto generated by Found's Play-tool at 2013-11-14T11:31:15+01:00
version: 0
title: Simple case sensitive search
description: "Standard tokenization, but without the lowercasing and stopword removal."
query:
match:
title:
# This will only match the first document.
query: Foo
---
query:
match:
title:
# This will match the second document only
query: foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment