Created
January 15, 2013 21:56
-
-
Save polyfractal/4542494 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
#create a test index with shingle mapping | |
curl -XPUT localhost:9200/test -d '{ | |
"settings":{ | |
"index":{ | |
"analysis":{ | |
"analyzer":{ | |
"analyzer_shingle":{ | |
"tokenizer":"standard", | |
"filter":["standard", "lowercase", "filter_stop", "filter_shingle"] | |
} | |
}, | |
"filter":{ | |
"filter_shingle":{ | |
"type":"shingle", | |
"max_shingle_size":5, | |
"min_shingle_size":2, | |
"output_unigrams":"true" | |
}, | |
"filter_stop":{ | |
"type":"stop", | |
"enable_position_increments":"false" | |
} | |
} | |
} | |
} | |
}, | |
"mappings":{ | |
"product":{ | |
"properties":{ | |
"title":{ | |
"search_analyzer":"analyzer_shingle", | |
"index_analyzer":"analyzer_shingle", | |
"type":"string" | |
} | |
} | |
} | |
} | |
}' | |
#Add some docs to the index | |
curl -XPOST localhost:9200/test/product/1 -d '{"title" : "Sample product title for shingles"}' | |
curl -XPOST localhost:9200/test/product/2 -d '{"title" : "Another title"}' | |
curl -XPOST localhost:9200/test/product/3 -d '{"title" : "Shingles is a viral disease"}' | |
#Analyze API to check out shingling | |
curl -XGET 'localhost:9200/test/_analyze?analyzer=analyzer_shingle&pretty' -d 'Test text to see shingles' | grep token | |
#Sample search | |
curl -XGET 'localhost:9200/test/product/_search?q=title:product+title&pretty' | |
#this one won't return anything, because of the stop filter | |
curl -XGET 'localhost:9200/test/product/_search?q=title:is+a&pretty' | |
#while this one will, because we emit unigrams | |
curl -XGET 'localhost:9200/test/product/_search?q=title:is+a+viral&pretty' |
This one is working with the latest ES version 7 -
PUT /moviesdb
{
"settings": {
"index": {
"number_of_shards": 1,
"analysis": {
"analyzer": {
"analyzer_shingle": {
"tokenizer": "standard",
"filter": [
"lowercase",
"filter_stop",
"filter_shingle"
]
}
},
"filter": {
"filter_shingle": {
"type": "shingle",
"min_shingle_size": 2,
"max_shingle_size": 4,
"output_unigrams": "true"
},
"filter_stop": {
"type": "stop"
}
}
}
}
},
"mappings": {
"properties": {
"title": {
"analyzer": "analyzer_shingle",
"type": "text"
}
}
}
}
You can simply copy it since I have gone through 3-4 posts to get rid of all my errors.
I have the same question as renatalucia. Can we do fuzzy searches with this? How?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ES 7.5.2
1st error:
and 2nd, after adding -H 'Content-Type: application/json' :