This repository was archived by the owner on Apr 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo.sh
More file actions
executable file
·124 lines (122 loc) · 6.35 KB
/
demo.sh
File metadata and controls
executable file
·124 lines (122 loc) · 6.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
function reportSuccess {
RETVAL=$?
if [ $RETVAL -eq 0 ];
then
echo success
else
echo failure
fi
}
echo
echo Testing English documents and queries:
echo
echo 1. Deleting the \'rosette-test-eng\' index which may exist from a previous run of this script...
curl -XDELETE 'http://localhost:9200/rosette-test-eng' && echo
echo
echo 2. Instantiating a \'rosette-test-eng\' index and associating an English Rosette Analyzer...
curl -XPUT 'http://localhost:9200/rosette-test-eng' -d '{
"settings": {
"analysis": {
"analyzer": {
"rosetteAnalyzerEng": {
"type": "rosette",
"bt.lang": "eng"
}
}
}
}
}' && echo
echo
echo 3. Specifying the \'typeEnglish\' doc type and that we want the English analyzer to parse the \'body\' text...
curl -XPUT 'http://localhost:9200/rosette-test-eng/typeEnglish/_mapping' -d '{
"typeEnglish": {
"properties" : {
"body" : { "type" : "string", "analyzer" : "rosetteAnalyzerEng" }
}
}
}' && echo
echo
echo 4. Adding four English documents to the \'rosette-test-eng\' index...
curl -XPUT 'http://localhost:9200/rosette-test-eng/typeEnglish/1' -d '{"body": "The quick brown fox jumps over the lazy dog."}' && echo
curl -XPUT 'http://localhost:9200/rosette-test-eng/typeEnglish/2' -d '{"body": "I painted the barn brown."}' && echo
curl -XPUT 'http://localhost:9200/rosette-test-eng/typeEnglish/3' -d '{"body": "The celebrities eagerly anticipated the Oscars."}' && echo
curl -XPUT 'http://localhost:9200/rosette-test-eng/typeEnglish/4' -d '{"body": "The celebrations are scheduled for next month."}' && echo
echo
echo 5. Refreshing the index so the newly indexed documents are available for queries...
curl -XPOST 'http://localhost:9200/rosette-test-eng/_refresh' && echo
echo
echo 6. Running four queries and grepping for the ids of the documents found for each...
echo
echo "Should return 1:"
curl -s 'http://localhost:9200/rosette-test-eng/typeEnglish/_search?pretty=true' -d '{"query": {"query_string": {"query": "body:lazy"}}, "fields":["_id"]}' | grep "_id" | tr '\n' ' ' | grep "id.\+1"
reportSuccess
echo
echo "Should return 1, 2:"
curl -s 'http://localhost:9200/rosette-test-eng/typeEnglish/_search?pretty=true' -d '{"query": {"query_string": {"query": "body:brown"}}, "fields":["_id"]}' | grep "_id" | tr '\n' ' ' | grep "id.\+2.\+id.\+1"
reportSuccess
echo
echo "Should return 1:"
curl -s 'http://localhost:9200/rosette-test-eng/typeEnglish/_search?pretty=true' -d '{"query": {"query_string": {"query": "body:jump"}}, "fields":["_id"]}' | grep "_id" | tr '\n' ' ' | grep "id.\+1"
reportSuccess
echo
echo "Should return 3:"
curl -s 'http://localhost:9200/rosette-test-eng/typeEnglish/_search?pretty=true' -d '{"query": {"query_string": {"query": "body:celebrity"}}, "fields":["_id"]}' | grep "_id" | tr '\n' ' ' | grep "id.\+3"
reportSuccess
echo
echo Testing Japanese documents and queries:
echo
echo 1. Deleting the \'rosette-test-jpn\' index which may exist from a previous run of this script...
curl -XDELETE 'http://localhost:9200/rosette-test-jpn' && echo
echo
echo 2. Instantiating the \'rosette-test-jpn\' index and associating a Japanese Rosette Analyzer...
curl -XPUT 'http://localhost:9200/rosette-test-jpn' -d '{
"settings": {
"analysis": {
"analyzer": {
"rosetteAnalyzerJpn": {
"type": "rosette",
"bt.lang": "jpn"
}
}
}
}
}' && echo
echo
echo 3. Specifying the \'typeJapanese\' doc type and that we want the Japanese analyzer to parse the \'body\' text...
curl -XPUT 'http://localhost:9200/rosette-test-jpn/typeJapanese/_mapping' -d '{
"typeJapanese": {
"properties" : {
"body" : { "type" : "string", "analyzer" : "rosetteAnalyzerJpn" }
}
}
}' && echo
echo
echo 4. Adding four Japanese documents to the \'rosette-test-jpn\' index...
curl -XPUT 'http://localhost:9200/rosette-test-jpn/typeJapanese/1' -d '{"body": "T水泳の世界選手権第11日は27日、豪州・メルボルンで行われ、女子百メートル背泳ぎ決勝で中村礼子(東京SC)が1分0秒40の日本人として大会初の銅メダルを獲得した。"}' && echo
curl -XPUT 'http://localhost:9200/rosette-test-jpn/typeJapanese/2' -d '{"body": "優勝は59秒44の世界新をマークしたアメリカ人のナタリー・コーグリン。"}' && echo
curl -XPUT 'http://localhost:9200/rosette-test-jpn/typeJapanese/3' -d '{"body": "女子千五百メートル自由形決勝では、柴田亜衣(チームアリーナ)が15分58秒55をマークし、2日続けて同種目の日本記録を更新し銅メダル。"}' && echo
curl -XPUT 'http://localhost:9200/rosette-test-jpn/typeJapanese/4' -d '{"body": "男子百メートル背泳ぎ決勝は、アーロン・ピアソル(米)が52秒98の世界新で優勝し、森田智己(セントラルスポーツ)は8位。"}' && echo
curl -XPOST 'http://localhost:9200/rosette-test-jpn/_refresh' && echo
echo
echo 5. Refreshing the index so the newly indexed documents are available for queries...
curl -XPOST 'http://localhost:9200/rosette-test-jpn/_refresh' && echo
echo
echo 6. Running four Japanese queries and grepping for the ids of the documents found for each...
echo
echo "Should return 1:"
curl -s 'http://localhost:9200/rosette-test-jpn/typeJapanese/_search?pretty=true' -d '{"query": {"query_string": {"query": "body:豪州"}}, "fields":[ "_id"]}' | grep "_id" | tr '\n' ' ' | grep "id.\+1"
reportSuccess
echo
echo "Should return 2:"
curl -s 'http://localhost:9200/rosette-test-jpn/typeJapanese/_search?pretty=true' -d '{"query": {"query_string": {"query": "body:コーグリン"}}, "fields":["_id"]}' | grep "_id" | tr '\n' ' ' | grep "id.\+2"
reportSuccess
echo
echo "Should return 3:"
curl -s 'http://localhost:9200/rosette-test-jpn/typeJapanese/_search?pretty=true' -d '{"query": {"query_string": {"query": "body:柴田亜衣"}}, "fields":["_id"]}' | grep "_id" | tr '\n' ' ' | grep "id.\+3"
reportSuccess
echo
echo "Should return 4:"
curl -s 'http://localhost:9200/rosette-test-jpn/typeJapanese/_search?pretty=true' -d '{"query": {"query_string": {"query": "body:アーロン"}}, "fields":["_id"]}' | grep "_id" | tr '\n' ' ' | grep "id.\+4"
reportSuccess
echo
echo Done.