Skip to content

Instantly share code, notes, and snippets.

@ofavre
Created March 15, 2013 11:12
Show Gist options
  • Save ofavre/5169100 to your computer and use it in GitHub Desktop.
Save ofavre/5169100 to your computer and use it in GitHub Desktop.
Curl recreation for Combo Analyzer demo with frankzappasmoustache's configuration
#!/bin/bash
# Install ES 0.90.0.Beta1
[ -f elasticsearch-0.90.0.Beta1.tar.gz ] || wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.0.Beta1.tar.gz -O elasticsearch-0.90.0.Beta1.tar.gz
mkdir es-combo-demo
tar xf elasticsearch-0.90.0.Beta1.tar.gz -C es-combo-demo
cd es-combo-demo/elasticsearch-0.90.0.Beta1
# Configure it
cat >config/elasticsearch.yml <<EOF
cluster.name: elasticsearch-demo-combo
http.port: 9242
index.number_of_shards: 1
index.number_of_replicas: 0
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: []
index:
analysis:
analyzer:
ngram:
tokenizer: whitespace
filter:
- standard
- lowercase
- ngram
- catenate_words
combo:
type: combo
sub_analyzers:
- standard
- ngram
filter:
catenate_words:
type: word_delimiter
catenate_all: true
generate_word_parts: true
generate_number_parts: false
split_on_case_change: false
split_on_numerics: false
preserve_original: true
stem_english_possessive: false
ngram:
type: nGram
min_gram: 3
max_gram: 50
EOF
# Install the Combo Analyzer plugin
bin/plugin -install com.yakaz.elasticsearch.plugins/elasticsearch-analysis-combo/1.3.0
# Start Es
bin/elasticsearch -f &
pid=$!
# Wait for it
while ! curl -s -XGET 'http://localhost:9242/_cluster/health' > /dev/null; do sleep 1; done
curl -s -XGET 'http://localhost:9242/_cluster/health?wait_for_status=green' > /dev/null
# Test
curl -XPUT 'http://localhost:9242/indexname/'
sleep 1
curl -XGET 'http://localhost:9242/indexname/_analyze?analyzer=combo&text=hello%20world&pretty=true'
# Shut it down
curl -XPOST 'http://localhost:9242/_shutdown'
wait $pid
# Clean up
cd ../..
rm -Rf es-combo-demo/
@kshnurov
Copy link

kshnurov commented Apr 6, 2013

Try running this several times

curl -XGET 'http://localhost:9242/indexname/_analyze?analyzer=combo&text=hello%20world&pretty=true'

and you'll get an error:

[2013-04-07 01:26:02,422][DEBUG][action.admin.indices.analyze] [Gin Genie] failed to execute [org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest@77f2fbff]
java.lang.UnsupportedOperationException
    at org.apache.lucene.analysis.ReusableTokenStreamComponents.setReader(ReusableTokenStreamComponents.java:20)
    at org.apache.lucene.analysis.Analyzer.tokenStream(Analyzer.java:137)
    at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:201)
    at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:57)
    at org.elasticsearch.action.support.single.custom.TransportSingleCustomOperationAction$AsyncSingleAction$2.run(TransportSingleCustomOperationAction.java:175)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
{
  "error" : "UnsupportedOperationException[null]",
  "status" : 500
}[2013-04-07 01:26:02,444][DEBUG][action.admin.indices.analyze] [Gin Genie] failed to execute [org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest@2f63e9a1]
java.lang.UnsupportedOperationException
    at org.apache.lucene.analysis.ReusableTokenStreamComponents.setReader(ReusableTokenStreamComponents.java:20)
    at org.apache.lucene.analysis.Analyzer.tokenStream(Analyzer.java:137)
    at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:201)
    at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:57)
    at org.elasticsearch.action.support.single.custom.TransportSingleCustomOperationAction$AsyncSingleAction$2.run(TransportSingleCustomOperationAction.java:175)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
{
  "error" : "UnsupportedOperationException[null]",
  "status" : 500
}

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