酒店api

  1. GET /hotel_price/_search
  2. {
  3. "query": {
  4. "match_all": {
  5. }
  6. }
  7. ,
  8. "from":1,
  9. "size":10
  10. }
  11. GET _cat/indices?v
  12. GET /hotel_price/_mget
  13. {
  14. "ids":["2_6073_2021-05-24","2_6086_2021-08-05"]
  15. }
  16. # 获取mapping关系
  17. GET /hotel_price/_mapping
  18. GET /hotel_price/_search/
  19. {
  20. "query": {
  21. "bool": {
  22. "must": [
  23. {
  24. "query_string": {
  25. "default_field": "hotel_name",
  26. "query": "如家"
  27. }
  28. }
  29. ],
  30. "filter": {
  31. "range": {
  32. "@timestamp": {
  33. "gte": "now-30d/d",
  34. "lte": "now/d"
  35. }
  36. }
  37. }
  38. }
  39. },
  40. "size": 20
  41. }
  42. GET /hotel_price/_search
  43. {
  44. "query": {
  45. "bool": {
  46. "must": [
  47. {
  48. "match": {
  49. "hotel_name": "汉庭"
  50. }
  51. }
  52. ],
  53. "filter": {
  54. "range": {
  55. "@timestamp": {
  56. "gte": "now-30d/d",
  57. "lte": "now/d"
  58. }
  59. }
  60. }
  61. }
  62. },
  63. "size": 10,
  64. "sort": [
  65. {
  66. "_id": {
  67. "order": "desc"
  68. }
  69. }
  70. ],
  71. "highlight": {
  72. "fields": {
  73. "hotel_name":{
  74. "pre_tags": ["<emm>"],
  75. "post_tags": ["</emm>"]
  76. }
  77. }
  78. }
  79. }
  80. ### 更新图片 旧值更新为新值
  81. POST hotel_price_2021.08.05/_update_by_query
  82. {
  83. "script": {
  84. "source": "ctx._source['coverimage_href']='https://pavo.elongstatic.com/i/Hotel870_470/nw_WANm5wXZHq.jpg';ctx._source['coverimage_href']='http://pavo.elongstatic.com/i/API350_350/42cbd6ae3e1524071e82d3ccc22a9a39.jpg'"
  85. },
  86. "query": {
  87. "bool": {
  88. "must": [
  89. {
  90. "term": {
  91. "mapping_id": {
  92. "value": "1839"
  93. }
  94. }
  95. }, {
  96. "term": {
  97. "prov_code": {
  98. "value": "1"
  99. }
  100. }
  101. }
  102. ]
  103. }
  104. }
  105. }
  106. get _template/hotel_price_template
  107. get hotel_price_2021.08.05/_count
  108. {
  109. "query":{
  110. "match_all" : {}
  111. }
  112. }
  113. POST hotel_price_2021.04.14/_update_by_query
  114. {
  115. "script": {
  116. "source": "ctx._source['agreement']='[{\"CompanyId\":\"1fbce0d1-d25a-cbd7-1929-08d763a92d4e\",\"AgreementCode\":\"slys_xy\"}]';ctx._source['has_agreement']='1'"
  117. },
  118. "query":{
  119. "bool" : {
  120. "must" : [
  121. {
  122. "term" : {
  123. "prov_code" : {
  124. "value" : "2"
  125. }
  126. }
  127. }
  128. ],
  129. "filter" : [
  130. {
  131. "term" : {
  132. "hotel_id" : {
  133. "value" : "859"
  134. }
  135. }
  136. }
  137. ]}
  138. }
  139. }
  140. POST hotel_price_2021.04.14/_update_by_query
  141. {
  142. "script": {
  143. "source": "ctx._source['agreement']='[]';ctx._source['has_agreement']='1'"
  144. },
  145. "query":{
  146. "match": {
  147. "hotel_id":"859"
  148. }
  149. }
  150. }
  151. get hotel_price/_search
  152. {
  153. "query":{
  154. "bool" : {
  155. "must" : [
  156. {
  157. "term" : {
  158. "prov_code" : {
  159. "value" : "1"
  160. }
  161. }
  162. }
  163. ],
  164. "filter" : [
  165. {
  166. "term" : {
  167. "hotel_id" : {
  168. "value" : "19188"
  169. }
  170. }
  171. }
  172. ]}
  173. },
  174. "collapse": {
  175. "field": "hotel_id"
  176. }
  177. }
  178. get _cat/count?v&pretty
  179. #delete hotel_price_2021.05.08
  180. get hotel_price_2021.06.15/_search
  181. {
  182. "query":{
  183. "match": {
  184. "hotel_name":"重庆格林"
  185. }
  186. }
  187. }
  188. get hotel_price_2021.08.05/_search
  189. {
  190. "query":{
  191. "match": {
  192. "hotel_name":"君庭"
  193. }
  194. }
  195. }
  196. get hotel_price_2021.08.05/_count
  197. {
  198. "query":{
  199. "match_all" : {}
  200. }
  201. }
  202. get hotel_price/_search
  203. {
  204. "query":{
  205. "match": {
  206. "hotel_id":"6583"
  207. }
  208. }
  209. }
  210. get hotel_price/_search
  211. {
  212. "query":{
  213. "match": {
  214. "hotel_id":"6583"
  215. }
  216. }
  217. }
  218. POST /_aliases
  219. {
  220. "actions" : [
  221. { "remove" : { "index" : "hotel_price_2021.06.15", "alias" : "hotel_price" } }
  222. { "add" : { "index" : "hotel_price_2021.08.05", "alias" : "hotel_price" } }
  223. ]
  224. }
  225. GET hotel_price/_search
  226. {
  227. "query": {
  228. "bool": {
  229. "must": [
  230. {
  231. "term": {
  232. "city_id": {
  233. "value": "34",
  234. "boost": 1
  235. }
  236. }
  237. }
  238. ],
  239. "filter": [
  240. {
  241. "match_phrase": {
  242. "hotel_name": {
  243. "query": "君亭",
  244. "slop": 4,
  245. "zero_terms_query": "NONE",
  246. "boost": 1
  247. }
  248. }
  249. },
  250. {
  251. "range": {
  252. "price": {
  253. "from": "0",
  254. "to": "99999",
  255. "include_lower": true,
  256. "include_upper": true,
  257. "boost": 1
  258. }
  259. }
  260. },
  261. {
  262. "range": {
  263. "biz_date": {
  264. "from": "2021-08-09",
  265. "to": "2021-08-11",
  266. "include_lower": true,
  267. "include_upper": true,
  268. "boost": 1
  269. }
  270. }
  271. },
  272. {
  273. "bool": {
  274. "should": [
  275. {
  276. "term": {
  277. "star_rate": {
  278. "value": "0",
  279. "boost": 1
  280. }
  281. }
  282. },
  283. {
  284. "term": {
  285. "star_rate": {
  286. "value": "1",
  287. "boost": 1
  288. }
  289. }
  290. },
  291. {
  292. "term": {
  293. "star_rate": {
  294. "value": "2",
  295. "boost": 1
  296. }
  297. }
  298. },
  299. {
  300. "term": {
  301. "star_rate": {
  302. "value": "3",
  303. "boost": 1
  304. }
  305. }
  306. },
  307. {
  308. "term": {
  309. "star_rate": {
  310. "value": "4",
  311. "boost": 1
  312. }
  313. }
  314. },
  315. {
  316. "term": {
  317. "star_rate": {
  318. "value": "5",
  319. "boost": 1
  320. }
  321. }
  322. }
  323. ],
  324. "adjust_pure_negative": true,
  325. "boost": 1
  326. }
  327. },
  328. {
  329. "bool": {
  330. "adjust_pure_negative": true,
  331. "boost": 1
  332. }
  333. }
  334. ],
  335. "adjust_pure_negative": true,
  336. "boost": 1
  337. }
  338. }
  339. }

电商搜索

  1. GET /goods/_search
  2. {
  3. "query": {
  4. "bool": {
  5. "must": [
  6. {
  7. "match": {
  8. "title": {
  9. "query": "手机",
  10. "operator": "and"
  11. }
  12. }
  13. }
  14. ],
  15. "filter": [
  16. {
  17. "nested": {
  18. "path": "attrs",
  19. "query": {
  20. "bool": {
  21. "must": [
  22. {
  23. "term": {
  24. "attrs.attrId": {
  25. "value": "9"
  26. }
  27. }
  28. },
  29. {
  30. "terms": {
  31. "attrs.attrValue": ["5","6","7"]
  32. }
  33. }
  34. ]
  35. }
  36. }
  37. }
  38. },
  39. {
  40. "nested": {
  41. "path": "attrs",
  42. "query": {
  43. "bool": {
  44. "must": [
  45. {
  46. "term": {
  47. "attrs.attrId": {
  48. "value": "4"
  49. }
  50. }
  51. },
  52. {
  53. "terms": {
  54. "attrs.attrValue": ["8G", "12G"]
  55. }
  56. }
  57. ]
  58. }
  59. }
  60. }
  61. },
  62. {
  63. "terms": {
  64. "brandId": [1,2,3]
  65. }
  66. },
  67. {
  68. "terms": {
  69. "categoryId": [225]
  70. }
  71. },
  72. {
  73. "range": {
  74. "price": {
  75. "gte": 0,
  76. "lte": 10000
  77. }
  78. }
  79. }
  80. ]
  81. }
  82. },
  83. "from": 0,
  84. "size": 10,
  85. "highlight": {
  86. "fields": {
  87. "name": {}
  88. },
  89. "pre_tags": "<b style='color:red'>",
  90. "post_tags": "</b>"
  91. },
  92. "sort": [
  93. {
  94. "price": {
  95. "order": "desc"
  96. }
  97. }
  98. ],
  99. "aggs": {
  100. "brandIdAgg": {
  101. "terms": {
  102. "field": "brandId"
  103. },
  104. "aggs": {
  105. "brandNameAgg": {
  106. "terms": {
  107. "field": "brandName"
  108. }
  109. }
  110. }
  111. },
  112. "categoryIdAgg": {
  113. "terms": {
  114. "field": "categoryId"
  115. },
  116. "aggs": {
  117. "categoryNameAgg": {
  118. "terms": {
  119. "field": "categoryName"
  120. }
  121. }
  122. }
  123. }
  124. }
  125. }