isearch/docs/Quickstart.md

91 lines
2.8 KiB
Markdown
Raw Normal View History

2021-04-02 16:14:05 +08:00
为了省去配置机器环境的麻烦建议通过docker来运行demo容器在终端执行如下命令
```
docker run -d intelligentsearch/isearch:latest
2021-04-02 16:14:05 +08:00
```
启动容器后,通过如下命令进入容器:
```
docker exec -it 容器id /bin/bash
```
容器id替换为上一步启动的容器对应的id
### 1. 查看项目配置文件
isearch应用的字段配置文件名称为app_field_define.txt通过以下指令查看配置文件内容
```
cat /usr/local/isearch/index_read/conf/app_field_define.txt
2021-04-02 16:14:05 +08:00
```
### 2. 上报索引数据
1tcp方式
2021-04-02 16:18:02 +08:00
2021-04-02 16:14:05 +08:00
执行如下命令进行测试数据的导入。
```
cd /usr/local/isearch/tools
2021-04-02 16:14:05 +08:00
./client_test send.json 106 127.0.0.1 11017
```
若屏幕显示如下信息,则表示数据导入成功:
```
send count == 1
recv: 27 bytes
server message: {"code":0}
```
可以通过修改send.json中的数据来导入更多的测试数据。
2http方式
2021-04-02 16:14:05 +08:00
执行如下命令
2021-04-02 16:14:05 +08:00
```
cd /usr/local/isearch/tools
sh load_data.sh
2021-04-02 16:14:05 +08:00
```
### 3. 测试搜索
2021-04-02 16:14:05 +08:00
执行如下命令进行数据的查询:
```
cd /usr/local/isearch/tools
// tcp方式
2021-04-02 16:14:05 +08:00
./client_test search.json 101 127.0.0.1 12003
// http方式
sh query.sh
2021-04-02 16:14:05 +08:00
```
以下为搜索结果的示例:
2021-04-02 16:14:05 +08:00
```
{
"code": 0,
"count": 1,
"result": [{
"doc_id": "12351",
"score": 11.689424985915906,
"title": "非洲特色动植物首次亮相北京市属公园 "
}]
}
```
以下是针对search.json中查询请求的说明
```
// match查询
{"appid":10010,"query":{"match":{"birthPlace":"上海市"}}}
{"appid":10010,"query":{"match":{"dreamPlace":"王国"}}}
{"appid":10010,"query":{"match":{"name":"Jackie"}}}
// term查询
{"appid":10010,"query":{"term":{"year":20}}}
// range查询
{"appid":10010,"query":{"range":{"height":{"gte":175 ,"lte": 180}}}}
// geo_distance查询
{"appid":10010,"query":{"geo_distance":{"currentLocation":"39.452, -76.589","distance":"0.5"}}}
// geo_polygon查询
{"appid":10010,"query":{"geo_polygon":{"currentShape":{"points":"POLYGON((121.437271 31.339747, 121.438022 31.337291, 121.435297 31.336814, 121.434524 31.339252, 121.437271 31.339747))"}}}}
// bool查询
{"appid":10010,"query":{"bool":{"must":{"match":{"birthPlace":"中华人民共和国"},"range":{"brithday":{"gt":19900654,"lte":19931124}}},"must_not":{"match":{"homeAddress":"上海市"}}}}}
{"appid":10010,"query":{"bool":{"must":{"match":{"birthPlace":"上海市"},"geo_distance":{"currentLocation":"39.452, -76.589","distance":"1.123"}}}}}
{"appid":10010,"query":{"bool":{"must":{"match":{"birthPlace":"上海市"},"term":{"gender":"男"}}}}}
// 通过page_index进行翻页
{"appid":10010,"query":{"match":{"dreamPlace":"阿姆斯"}},"fields":"birthPlace,homeAddress,dreamPlace,name","page_index":1,"page_size":3}
// 按height字段进行排序
{"appid":10010,"query":{"range":{"height":{"gte":174 ,"lte": 180}}},"fields":"birthPlace,height,name","sort_type":"5","sort_field":"height"}
2021-04-02 16:14:05 +08:00
```