/
preserve_phrases.sh
84 lines (83 loc) · 2.21 KB
/
preserve_phrases.sh
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
curl -XDELETE localhost:9200/test-idx
curl -XPUT localhost:9200/test-idx -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"analyzer": {
"synonym": {
"tokenizer": "standard",
"filter": ["lowercase","synonym"]
}
},
"filter": {
"synonym": {
"type": "synonym",
"synonyms": ["fashion police => fashion$police", "double jeopardy => double$jeopardy"]
}
}
}
}
},
"mappings": {
"doc": {
"properties": {
"name": {
"type": "string",
"index": "analyzed",
"analyzer": "synonym"
}
}
}
}
}
'
curl -XPUT "localhost:9200/test-idx/doc/1?pretty" -d '{
"name": "Police investigating possible double homicide"
}'
curl -XPUT "localhost:9200/test-idx/doc/2?pretty" -d '{
"name": "Fashion Police is an American television series airing on E!."
}'
curl -XPUT "localhost:9200/test-idx/doc/3?pretty" -d '{
"name": "Double Jeopardy!, the second round of the TV game show Jeopardy!"
}'
curl -XPOST "localhost:9200/test-idx/_refresh?pretty"
echo
echo "------------"
echo "Searching for Double"
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"match" : {
"name" : "Double"
}
},
"fields": ["name"]
}'
echo "Searching for Double Jeopardy"
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"match" : {
"name" : "Double Jeopardy"
}
},
"fields": ["name"]
}'
echo "Searching for police"
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"match" : {
"name" : "police"
}
},
"fields": ["name"]
}'
echo "Searching for fashion police"
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"match" : {
"name" : "fashion police"
}
},
"fields": ["name"]
}'