Skip to content

Commit 25def5f

Browse files
committed
Adding analysis curl examples
1 parent 29198b5 commit 25def5f

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

analysis.md

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
## With default mappings
2+
3+
### Index the documents
4+
5+
curl -XPUT 'http://localhost:9200/cities/city/1' -d'
6+
{
7+
"city": "Sandusky",
8+
"population": 25340
9+
}
10+
'
11+
12+
curl -XPUT 'http://localhost:9200/cities/city/2' -d'
13+
{
14+
"city": "New Albany",
15+
"population": 8829
16+
}
17+
'
18+
19+
curl -XPUT 'http://localhost:9200/cities/city/3' -d'
20+
{
21+
"city": "New York",
22+
"population": 8406000
23+
}
24+
'
25+
26+
### Query
27+
curl -XPOST 'http://localhost:9200/cities/_search' -d'
28+
{
29+
"query": {
30+
"match": {
31+
"city": "New Albany"
32+
}
33+
}
34+
}
35+
'
36+
37+
38+
## With `not_analyzed` mapping
39+
40+
### Cleanup
41+
curl -XDELETE 'http://localhost:9200/cities'
42+
43+
### Create index with mapping
44+
curl -XPUT 'http://localhost:9200/cities' -d'
45+
{
46+
"mappings": {
47+
"city": {
48+
"properties": {
49+
"city": {
50+
"type": "string",
51+
"index": "not_analyzed"
52+
}
53+
}
54+
}
55+
}
56+
}
57+
'
58+
59+
### Index the documents
60+
61+
curl -XPUT 'http://localhost:9200/cities/city/1' -d'
62+
{
63+
"city": "Sandusky",
64+
"population": 25340
65+
}
66+
'
67+
68+
curl -XPUT 'http://localhost:9200/cities/city/2' -d'
69+
{
70+
"city": "New Albany",
71+
"population": 8829
72+
}
73+
'
74+
75+
curl -XPUT 'http://localhost:9200/cities/city/3' -d'
76+
{
77+
"city": "New York",
78+
"population": 8406000
79+
}
80+
'
81+
82+
### Query
83+
curl -XPOST 'http://localhost:9200/cities/_search' -d'
84+
{
85+
"query": {
86+
"match": {
87+
"city": "New Albany"
88+
}
89+
}
90+
}
91+
'

0 commit comments

Comments
 (0)