-
Notifications
You must be signed in to change notification settings - Fork 9
/
similarities.sh
executable file
·95 lines (95 loc) · 2.7 KB
/
similarities.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
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#
# This script demonstrates how to test different similarities for the same field
#
#
curl -XDELETE "localhost:9200/test-idx?pretty"
curl -XPUT "localhost:9200/test-idx?pretty" -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0,
"similarity": {
"my_bm25": {
"type": "BM25"
},
"my_dfr": {
"type": "DFR",
"basic_model": "be",
"after_effect": "no",
"normalization": "no"
},
"my_ib": {
"type": "IB",
"distribution": "ll",
"lambda": "df",
"normalization": "no"
}
}
}
},
"mappings": {
"doc": {
"properties": {
"my_data": {
"type": "string",
"fields": {
"bm25": {
"type": "string",
"similarity": "my_bm25"
},
"dfr": {
"type": "string",
"similarity": "my_dfr"
},
"ib": {
"type": "string",
"similarity": "my_ib"
}
}
}
}
}
}
}
'
curl -XPUT "localhost:9200/test-idx/doc/1?pretty" -d '{"my_data": "similiarity is awesome in this test"}'
curl -XPUT "localhost:9200/test-idx/doc/2?pretty" -d '{"my_data": "similiarity in this similiarity test"}'
curl -XPUT "localhost:9200/test-idx/doc/3?pretty" -d '{"my_data": "test it all the way in this test"}'
curl -XPOST "localhost:9200/test-idx/_refresh?pretty"
echo "Default simliarity"
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"match": {
"my_data": "similiarity test"
}
},
"fields": ["my_data"]
}'
echo "BM25 simliarity"
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"match": {
"my_data.bm25": "similiarity test"
}
},
"fields": ["my_data"]
}'
echo "DFR simliarity"
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"match": {
"my_data.dfr": "similiarity test"
}
},
"fields": ["my_data"]
}'
echo "IB simliarity"
curl "localhost:9200/test-idx/doc/_search?pretty=true" -d '{
"query": {
"match": {
"my_data.ib": "similiarity test"
}
},
"fields": ["my_data"]
}'