Skip to content

Commit 3971152

Browse files
author
cuidapeng
committed
pub
1 parent 65d501d commit 3971152

File tree

1 file changed

+127
-2
lines changed

1 file changed

+127
-2
lines changed

README.md

100644100755
Lines changed: 127 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,127 @@
1-
# elasticsearch-filter-limitbyfreq
2-
elasticsearch token limit by freq
1+
Limit Token Filter for Elasticsearch
2+
==================================
3+
4+
Filter: limit_by_freq
5+
6+
Parameter: max_token_count(default:512)
7+
8+
Desc: token order by freq desc and limit top
9+
10+
freq num is stored in 'payload' to be used in future
11+
12+
Install
13+
-------
14+
15+
1.download or compile
16+
17+
* download pre-build package from here: https://github.com/cclient/elasticsearch-filter-limitbyfreq/releases
18+
19+
unzip plugin to folder `your-es-root/plugins/`
20+
21+
2.restart elasticsearch
22+
23+
24+
#### Quick Example
25+
26+
1.create a index
27+
28+
```bash
29+
curl -XPUT http://localhost:9200/test_index -d'
30+
{
31+
"settings": {
32+
"analysis": {
33+
"filter": {
34+
"my_limit": {
35+
"type":"limit_by_freq",
36+
"max_token_count":2
37+
}
38+
},
39+
"analyzer": {
40+
"limit_test": {
41+
"tokenizer": "standard",
42+
"filter": [
43+
"my_limit"
44+
]
45+
}
46+
}
47+
}
48+
},
49+
"mappings": {
50+
"test": {
51+
"properties": {
52+
"desc": {
53+
"type": "text",
54+
"analyzer": "limit_test"
55+
}
56+
}
57+
}
58+
}
59+
}'
60+
```
61+
62+
2.test
63+
64+
```bash
65+
curl -XPOST http://localhost:9200/test_index/_analyze?tokenizer=standard&filter=limit_by_freq -d'
66+
hello hyper log log'
67+
```
68+
69+
Result
70+
71+
```json
72+
{
73+
"tokens": [
74+
{
75+
"token": "log",
76+
"start_offset": 0,
77+
"end_offset": 0,
78+
"type": "TOP_TOKEN",
79+
"position": 0
80+
},
81+
{
82+
"token": "hello",
83+
"start_offset": 0,
84+
"end_offset": 0,
85+
"type": "TOP_TOKEN",
86+
"position": 1
87+
},
88+
{
89+
"token": "hyper",
90+
"start_offset": 0,
91+
"end_offset": 0,
92+
"type": "TOP_TOKEN",
93+
"position": 2
94+
}
95+
]
96+
}
97+
```
98+
99+
100+
101+
```bash
102+
curl -XPOST http://127.0.0.1:9200/test_index/_analyze?analyzer=limit_test -d'
103+
hello hyper log log'
104+
```
105+
106+
Result
107+
108+
```json
109+
{
110+
"tokens": [
111+
{
112+
"token": "log",
113+
"start_offset": 0,
114+
"end_offset": 0,
115+
"type": "TOP_TOKEN",
116+
"position": 0
117+
},
118+
{
119+
"token": "hello",
120+
"start_offset": 0,
121+
"end_offset": 0,
122+
"type": "TOP_TOKEN",
123+
"position": 1
124+
}
125+
]
126+
}
127+
```

0 commit comments

Comments
 (0)