一、 添加測試數據
1、創建索引和映射結構
curl -XPUT 'http://192.168.3.27:8201/test_index?pretty' \
-H "Content-Type: application/json" \
-d '{"settings":{"number_of_shards":2,"number_of_replicas":1},"mappings":{"properties":{"text":{"type":"text","analyzer":"ik_smart"},"type":{"type": "keyword"},"publish_date": {"type": "date"}}}}'
mapping中字段類型:
1、基本類型text,keyword,date,long,double,boolean,ip,text和keyword都可以保存字符串,text會被解析,keyword適合要進行過濾、排序、聚合的字段,搜索時要使用精確查詢;
2、Json的層級類型,可以保存多層級Json內容;
3、複雜的類型,geo_point地理位置信息等。
2、添加測試數據
添加四條測試數據(數據這裏審覈不通過)
新聞地址:https://baijiahao.baidu.com/s?id=1669616707242562645&wfr=spider&for=pc,取其中內容放入text中
curl -XPUT 'http://192.168.3.27:8201/test_index/_doc/1?pretty' \
-H "Content-Type: application/json" \
-d '{"text":"","typ