elasticsearch实现类似京东的商品搜索效果(elasticsearch动态聚合)

小灰灰 2023-07-24 08:49 43阅读 0赞

用到京东的对其搜索应该不会陌生,其搜索也是使用elasticsearch完成的,下图为一个搜索效果图:

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvaG4xMzM3_size_16_color_FFFFFF_t_70

搜索筛选条件会根据查询返回的结果动态变化,要实现这个功能就要用到elasticsearch的聚合功能,先看下商品索引对应的映射:

  1. {
  2. "mapping": {
  3. "es-product": {
  4. "dynamic_templates": [
  5. {
  6. "strings_as_keyword": {
  7. "match_mapping_type": "string",
  8. "mapping": {
  9. "type": "keyword"
  10. }
  11. }
  12. }
  13. ],
  14. "properties": {
  15. "aggProperties": {
  16. "type": "nested",
  17. "properties": {
  18. "key": {
  19. "type": "keyword"
  20. },
  21. "value": {
  22. "type": "keyword"
  23. }
  24. }
  25. },
  26. "brandName": {
  27. "type": "keyword"
  28. },
  29. "id": {
  30. "type": "keyword"
  31. },
  32. "level1Category": {
  33. "type": "keyword"
  34. },
  35. "level2Category": {
  36. "type": "keyword"
  37. },
  38. "level3Category": {
  39. "type": "keyword"
  40. },
  41. "mainTitle": {
  42. "type": "text",
  43. "analyzer": "ik_max_word"
  44. },
  45. "searchProperties": {
  46. "properties": {
  47. "光泽度": {
  48. "type": "keyword"
  49. },
  50. "光源个数": {
  51. "type": "keyword"
  52. },
  53. "光源类型": {
  54. "type": "keyword"
  55. },
  56. "功率": {
  57. "type": "keyword"
  58. },
  59. "包装体积": {
  60. "type": "keyword"
  61. },
  62. "型号": {
  63. "type": "keyword"
  64. },
  65. "密度": {
  66. "type": "keyword"
  67. },
  68. "导热性": {
  69. "type": "keyword"
  70. },
  71. "导电性": {
  72. "type": "keyword"
  73. },
  74. "延展性": {
  75. "type": "keyword"
  76. },
  77. "抗氧化性": {
  78. "type": "keyword"
  79. },
  80. "是否带护栏": {
  81. "type": "keyword"
  82. },
  83. "是否带软靠": {
  84. "type": "keyword"
  85. },
  86. "是否带遥控器": {
  87. "type": "keyword"
  88. },
  89. "照射面积": {
  90. "type": "keyword"
  91. },
  92. "熔点": {
  93. "type": "keyword"
  94. },
  95. "磁性": {
  96. "type": "keyword"
  97. },
  98. "表面机理": {
  99. "type": "keyword"
  100. },
  101. "适用人数": {
  102. "type": "keyword"
  103. },
  104. "适用空间": {
  105. "type": "keyword"
  106. },
  107. "风格": {
  108. "type": "keyword"
  109. }
  110. }
  111. },
  112. "subTitle": {
  113. "type": "keyword"
  114. }
  115. }
  116. }
  117. }
  118. }

searchProperties部分为动态属性,使用elasticsearch的dynamic template配置,aggProperties部分为动态聚合所用,通过aggProperties下面的值动态聚合满足条件的搜索结果所具有的所有属性,比如光泽度、熔点等,而searchProperties是为搜索使用,先说下属性动态聚合的实现,下面是elasticsearch的查询脚本:

  1. {
  2. "from" : 0, "size" : 100,
  3. "query": {
  4. "bool":{
  5. "must":[{
  6. "match" : {
  7. "mainTitle" : "拉手"
  8. }
  9. }
  10. ]
  11. }
  12. },
  13. "aggs": {
  14. "dynamicproperty": {
  15. "nested": {
  16. "path": "aggProperties"
  17. },
  18. "aggs": {
  19. "name": {
  20. "terms": {
  21. "field": "aggProperties.key"
  22. },
  23. "aggs": {
  24. "value": {
  25. "terms": {
  26. "field": "aggProperties.value"
  27. }
  28. }
  29. }
  30. }
  31. }
  32. }
  33. }
  34. }

通过上面的搜索得到下面结果:

  1. {
  2. "took": 13,
  3. "timed_out": false,
  4. "_shards": {
  5. "total": 3,
  6. "successful": 3,
  7. "skipped": 0,
  8. "failed": 0
  9. },
  10. "hits": {
  11. "total": 8,
  12. "max_score": 1.3591974,
  13. "hits": [
  14. {
  15. "_index": "smp-product",
  16. "_type": "es-product",
  17. "_id": "2c95ae137157829c017157c3c61c0089",
  18. "_score": 1.3591974,
  19. "_source": {
  20. "id": "2c95ae137157829c017157c3c61c0089",
  21. "mainTitle": "富达铭黑色隐形拉手免打孔铝合金拉手一字型暗拉手橱柜衣柜门长把手隐藏拉手长拉手 咖啡150mm",
  22. "subTitle": "",
  23. "brandName": "三叶",
  24. "aggProperties": [
  25. {
  26. "key": "密度",
  27. "value": "2000克/cm³"
  28. },
  29. {
  30. "key": "熔点",
  31. "value": "2000℃"
  32. },
  33. {
  34. "key": "导热性",
  35. "value": "很好"
  36. },
  37. {
  38. "key": "延展性",
  39. "value": "易锻物质,不需退火可锤炼可压延"
  40. },
  41. {
  42. "key": "导电性",
  43. "value": "是"
  44. },
  45. {
  46. "key": "磁性",
  47. "value": "顺磁材料"
  48. },
  49. {
  50. "key": "光泽度",
  51. "value": "哑光"
  52. },
  53. {
  54. "key": "表面机理",
  55. "value": "拉丝"
  56. },
  57. {
  58. "key": "抗氧化性",
  59. "value": "中"
  60. }
  61. ],
  62. "searchProperties": {
  63. "表面机理": "拉丝",
  64. "抗氧化性": "中",
  65. "导热性": "很好",
  66. "延展性": "易锻物质,不需退火可锤炼可压延",
  67. "磁性": "顺磁材料",
  68. "导电性": "是",
  69. "密度": "2000克/cm³",
  70. "熔点": "2000℃",
  71. "光泽度": "哑光"
  72. }
  73. }
  74. },
  75. {
  76. "_index": "smp-product",
  77. "_type": "es-product",
  78. "_id": "2c95ae137157829c017157ad040c004d",
  79. "_score": 1.2214447,
  80. "_source": {
  81. "id": "2c95ae137157829c017157ad040c004d",
  82. "mainTitle": "致诺 老式铁皮拉手 不锈钢拉手大木门蟹壳拉手 明装四孔铁皮门轻把手简易拉手老式通用型防盗门把手 大号2个价格",
  83. "subTitle": "",
  84. "brandName": "三叶",
  85. "aggProperties": [
  86. {
  87. "key": "密度",
  88. "value": "1000克/cm³"
  89. },
  90. {
  91. "key": "熔点",
  92. "value": "1000℃"
  93. },
  94. {
  95. "key": "导热性",
  96. "value": "较好"
  97. },
  98. {
  99. "key": "延展性",
  100. "value": "易锻物质,不需退火可锤炼可压延"
  101. }
  102. ],
  103. "searchProperties": {
  104. "导热性": "较好",
  105. "延展性": "易锻物质,不需退火可锤炼可压延",
  106. "密度": "1000克/cm³",
  107. "熔点": "1000℃"
  108. }
  109. }
  110. },
  111. {
  112. "_index": "smp-product",
  113. "_type": "es-product",
  114. "_id": "2c95ae137157829c017157a991b60011",
  115. "_score": 1.1077276,
  116. "_source": {
  117. "id": "2c95ae137157829c017157a991b60011",
  118. "mainTitle": "卡贝拉手衣柜门拉手抽屉橱柜衣柜鞋柜高档门把手现代简约五金配件",
  119. "subTitle": "",
  120. "brandName": "宗艺石材",
  121. "aggProperties": [
  122. {
  123. "key": "密度",
  124. "value": "1000克/cm³"
  125. },
  126. {
  127. "key": "熔点",
  128. "value": "2000℃"
  129. },
  130. {
  131. "key": "导热性",
  132. "value": "较好"
  133. },
  134. {
  135. "key": "导电性",
  136. "value": "否"
  137. },
  138. {
  139. "key": "磁性",
  140. "value": "顺磁材料"
  141. },
  142. {
  143. "key": "光泽度",
  144. "value": "哑光"
  145. },
  146. {
  147. "key": "表面机理",
  148. "value": "拉丝"
  149. },
  150. {
  151. "key": "抗氧化性",
  152. "value": "中"
  153. }
  154. ],
  155. "searchProperties": {
  156. "表面机理": "拉丝",
  157. "抗氧化性": "中",
  158. "导热性": "较好",
  159. "磁性": "顺磁材料",
  160. "导电性": "否",
  161. "密度": "1000克/cm³",
  162. "熔点": "2000℃",
  163. "光泽度": "哑光"
  164. }
  165. }
  166. },
  167. {
  168. "_index": "smp-product",
  169. "_type": "es-product",
  170. "_id": "2c95ae137157829c017157c5c98100a7",
  171. "_score": 0.77200073,
  172. "_source": {
  173. "id": "2c95ae137157829c017157c5c98100a7",
  174. "mainTitle": "CD超代欧式简约陶瓷衣柜柜门抽屉把手小拉手 田园大理石陶瓷酒柜拉手 单只价格 A7-96孔距-长120mm",
  175. "subTitle": "",
  176. "brandName": "三叶",
  177. "aggProperties": [
  178. {
  179. "key": "密度",
  180. "value": "1500克/cm³"
  181. },
  182. {
  183. "key": "熔点",
  184. "value": "1600℃"
  185. },
  186. {
  187. "key": "导热性",
  188. "value": "较好"
  189. },
  190. {
  191. "key": "延展性",
  192. "value": "易锻物质,不需退火可锤炼可压延"
  193. },
  194. {
  195. "key": "导电性",
  196. "value": "是"
  197. },
  198. {
  199. "key": "磁性",
  200. "value": "顺磁材料"
  201. },
  202. {
  203. "key": "光泽度",
  204. "value": "哑光"
  205. },
  206. {
  207. "key": "表面机理",
  208. "value": "拉丝"
  209. },
  210. {
  211. "key": "抗氧化性",
  212. "value": "高"
  213. }
  214. ],
  215. "searchProperties": {
  216. "表面机理": "拉丝",
  217. "抗氧化性": "高",
  218. "导热性": "较好",
  219. "延展性": "易锻物质,不需退火可锤炼可压延",
  220. "磁性": "顺磁材料",
  221. "导电性": "是",
  222. "密度": "1500克/cm³",
  223. "熔点": "1600℃",
  224. "光泽度": "哑光"
  225. }
  226. }
  227. },
  228. {
  229. "_index": "smp-product",
  230. "_type": "es-product",
  231. "_id": "2c95ae137157829c017157aaa03d0022",
  232. "_score": 0.7351246,
  233. "_source": {
  234. "id": "2c95ae137157829c017157aaa03d0022",
  235. "mainTitle": "适用于步阳群升新多星月神春天进户大门防盗门把手 拉手面板双快加厚实",
  236. "subTitle": "",
  237. "brandName": "西门子",
  238. "aggProperties": [
  239. {
  240. "key": "密度",
  241. "value": "1000克/cm³"
  242. },
  243. {
  244. "key": "熔点",
  245. "value": "1500℃"
  246. },
  247. {
  248. "key": "导热性",
  249. "value": "较好"
  250. },
  251. {
  252. "key": "延展性",
  253. "value": "易锻物质,不需退火可锤炼可压延"
  254. }
  255. ],
  256. "searchProperties": {
  257. "导热性": "较好",
  258. "延展性": "易锻物质,不需退火可锤炼可压延",
  259. "密度": "1000克/cm³",
  260. "熔点": "1500℃"
  261. }
  262. }
  263. },
  264. {
  265. "_index": "smp-product",
  266. "_type": "es-product",
  267. "_id": "2c95ae137157829c017157ac51f9003f",
  268. "_score": 0.6896249,
  269. "_source": {
  270. "id": "2c95ae137157829c017157ac51f9003f",
  271. "mainTitle": "防盗门把手拉手进户门拉手双活双快执手手柄加厚大门锁具配件 加厚铝合金门把手 >55mm 通用型 不带钥匙",
  272. "subTitle": "",
  273. "brandName": "西门子",
  274. "aggProperties": [
  275. {
  276. "key": "密度",
  277. "value": "1500克/cm³"
  278. },
  279. {
  280. "key": "熔点",
  281. "value": "2000℃"
  282. },
  283. {
  284. "key": "导热性",
  285. "value": "较好"
  286. },
  287. {
  288. "key": "延展性",
  289. "value": "易锻物质,不需退火可锤炼可压延"
  290. },
  291. {
  292. "key": "导电性",
  293. "value": "是"
  294. },
  295. {
  296. "key": "磁性",
  297. "value": "顺磁材料"
  298. },
  299. {
  300. "key": "光泽度",
  301. "value": "高光"
  302. },
  303. {
  304. "key": "表面机理",
  305. "value": "拉丝"
  306. },
  307. {
  308. "key": "抗氧化性",
  309. "value": "中"
  310. }
  311. ],
  312. "searchProperties": {
  313. "表面机理": "拉丝",
  314. "抗氧化性": "中",
  315. "导热性": "较好",
  316. "延展性": "易锻物质,不需退火可锤炼可压延",
  317. "磁性": "顺磁材料",
  318. "导电性": "是",
  319. "密度": "1500克/cm³",
  320. "熔点": "2000℃",
  321. "光泽度": "高光"
  322. }
  323. }
  324. },
  325. {
  326. "_index": "smp-product",
  327. "_type": "es-product",
  328. "_id": "2c95ae137157829c017157add2c8005c",
  329. "_score": 0.4982656,
  330. "_source": {
  331. "id": "2c95ae137157829c017157add2c8005c",
  332. "mainTitle": "汇乐斯 防盗门把手拉手执手大门把手门把手门锁把手锁体锁帽 面板把手一对/配件+外固定把手 左开",
  333. "subTitle": "",
  334. "brandName": "三棵树",
  335. "aggProperties": [
  336. {
  337. "key": "密度",
  338. "value": "1000克/cm³"
  339. },
  340. {
  341. "key": "熔点",
  342. "value": "1000℃"
  343. },
  344. {
  345. "key": "导热性",
  346. "value": "很好"
  347. },
  348. {
  349. "key": "延展性",
  350. "value": "易锻物质,不需退火可锤炼可压延"
  351. }
  352. ],
  353. "searchProperties": {
  354. "导热性": "很好",
  355. "延展性": "易锻物质,不需退火可锤炼可压延",
  356. "密度": "1000克/cm³",
  357. "熔点": "1000℃"
  358. }
  359. }
  360. },
  361. {
  362. "_index": "smp-product",
  363. "_type": "es-product",
  364. "_id": "2c95ae137157829c017157c4cb880098",
  365. "_score": 0.48578173,
  366. "_source": {
  367. "id": "2c95ae137157829c017157c4cb880098",
  368. "mainTitle": "防盗门把手拉手双活双快执手手柄大门锁配件铝合金门把手 加厚白金带点固定款(13*13) >55mm 通用型 不带钥匙",
  369. "subTitle": "",
  370. "brandName": "三叶",
  371. "aggProperties": [
  372. {
  373. "key": "密度",
  374. "value": "1500克/cm³"
  375. },
  376. {
  377. "key": "熔点",
  378. "value": "1500℃"
  379. },
  380. {
  381. "key": "导热性",
  382. "value": "较好"
  383. },
  384. {
  385. "key": "延展性",
  386. "value": "易锻物质,不需退火可锤炼可压延"
  387. },
  388. {
  389. "key": "导电性",
  390. "value": "否"
  391. },
  392. {
  393. "key": "磁性",
  394. "value": "铁磁材料"
  395. },
  396. {
  397. "key": "光泽度",
  398. "value": "高光"
  399. },
  400. {
  401. "key": "表面机理",
  402. "value": "拉丝"
  403. },
  404. {
  405. "key": "抗氧化性",
  406. "value": "中"
  407. }
  408. ],
  409. "searchProperties": {
  410. "表面机理": "拉丝",
  411. "抗氧化性": "中",
  412. "导热性": "较好",
  413. "延展性": "易锻物质,不需退火可锤炼可压延",
  414. "磁性": "铁磁材料",
  415. "导电性": "否",
  416. "密度": "1500克/cm³",
  417. "熔点": "1500℃",
  418. "光泽度": "高光"
  419. }
  420. }
  421. }
  422. ]
  423. },
  424. "aggregations": {
  425. "dynamicproperty": {
  426. "doc_count": 56,
  427. "name": {
  428. "doc_count_error_upper_bound": 0,
  429. "sum_other_doc_count": 0,
  430. "buckets": [
  431. {
  432. "key": "密度",
  433. "doc_count": 8,
  434. "value": {
  435. "doc_count_error_upper_bound": 0,
  436. "sum_other_doc_count": 0,
  437. "buckets": [
  438. {
  439. "key": "1000克/cm³",
  440. "doc_count": 4
  441. },
  442. {
  443. "key": "1500克/cm³",
  444. "doc_count": 3
  445. },
  446. {
  447. "key": "2000克/cm³",
  448. "doc_count": 1
  449. }
  450. ]
  451. }
  452. },
  453. {
  454. "key": "导热性",
  455. "doc_count": 8,
  456. "value": {
  457. "doc_count_error_upper_bound": 0,
  458. "sum_other_doc_count": 0,
  459. "buckets": [
  460. {
  461. "key": "较好",
  462. "doc_count": 6
  463. },
  464. {
  465. "key": "很好",
  466. "doc_count": 2
  467. }
  468. ]
  469. }
  470. },
  471. {
  472. "key": "熔点",
  473. "doc_count": 8,
  474. "value": {
  475. "doc_count_error_upper_bound": 0,
  476. "sum_other_doc_count": 0,
  477. "buckets": [
  478. {
  479. "key": "2000℃",
  480. "doc_count": 3
  481. },
  482. {
  483. "key": "1000℃",
  484. "doc_count": 2
  485. },
  486. {
  487. "key": "1500℃",
  488. "doc_count": 2
  489. },
  490. {
  491. "key": "1600℃",
  492. "doc_count": 1
  493. }
  494. ]
  495. }
  496. },
  497. {
  498. "key": "延展性",
  499. "doc_count": 7,
  500. "value": {
  501. "doc_count_error_upper_bound": 0,
  502. "sum_other_doc_count": 0,
  503. "buckets": [
  504. {
  505. "key": "易锻物质,不需退火可锤炼可压延",
  506. "doc_count": 7
  507. }
  508. ]
  509. }
  510. },
  511. {
  512. "key": "光泽度",
  513. "doc_count": 5,
  514. "value": {
  515. "doc_count_error_upper_bound": 0,
  516. "sum_other_doc_count": 0,
  517. "buckets": [
  518. {
  519. "key": "哑光",
  520. "doc_count": 3
  521. },
  522. {
  523. "key": "高光",
  524. "doc_count": 2
  525. }
  526. ]
  527. }
  528. },
  529. {
  530. "key": "导电性",
  531. "doc_count": 5,
  532. "value": {
  533. "doc_count_error_upper_bound": 0,
  534. "sum_other_doc_count": 0,
  535. "buckets": [
  536. {
  537. "key": "是",
  538. "doc_count": 3
  539. },
  540. {
  541. "key": "否",
  542. "doc_count": 2
  543. }
  544. ]
  545. }
  546. },
  547. {
  548. "key": "抗氧化性",
  549. "doc_count": 5,
  550. "value": {
  551. "doc_count_error_upper_bound": 0,
  552. "sum_other_doc_count": 0,
  553. "buckets": [
  554. {
  555. "key": "中",
  556. "doc_count": 4
  557. },
  558. {
  559. "key": "高",
  560. "doc_count": 1
  561. }
  562. ]
  563. }
  564. },
  565. {
  566. "key": "磁性",
  567. "doc_count": 5,
  568. "value": {
  569. "doc_count_error_upper_bound": 0,
  570. "sum_other_doc_count": 0,
  571. "buckets": [
  572. {
  573. "key": "顺磁材料",
  574. "doc_count": 4
  575. },
  576. {
  577. "key": "铁磁材料",
  578. "doc_count": 1
  579. }
  580. ]
  581. }
  582. },
  583. {
  584. "key": "表面机理",
  585. "doc_count": 5,
  586. "value": {
  587. "doc_count_error_upper_bound": 0,
  588. "sum_other_doc_count": 0,
  589. "buckets": [
  590. {
  591. "key": "拉丝",
  592. "doc_count": 5
  593. }
  594. ]
  595. }
  596. }
  597. ]
  598. }
  599. }
  600. }
  601. }

这样就在返回搜索结果的同时返回了满足条件的所有索引的动态属性,把aggregations中的数据处理后返回给前端就可以实现类似京东的商品搜索效果。

接下来给出基于RestHighLevelClient的客户端搜索实现:

  1. @Test
  2. public void aggregate2() throws IOException {
  3. SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
  4. BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
  5. boolQueryBuilder.must(QueryBuilders.matchQuery("mainTitle","拉手"));
  6. BoolQueryBuilder boolQueryBuilder1 = QueryBuilders.boolQuery();
  7. boolQueryBuilder1.must(QueryBuilders.matchQuery("props.key","密度"));
  8. boolQueryBuilder1.must(QueryBuilders.matchQuery("props.value","2000克/cm³"));
  9. NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("props",boolQueryBuilder1, ScoreMode.Total);
  10. searchSourceBuilder.query(nestedQueryBuilder);
  11. NestedAggregationBuilder level1Aggs = AggregationBuilders.nested("level1Agg","props");
  12. TermsAggregationBuilder propKeyAgg = AggregationBuilders.terms("keyAggs").field("props.key");
  13. level1Aggs.subAggregation(propKeyAgg);
  14. TermsAggregationBuilder propValAgg = AggregationBuilders.terms("valAggs").field("props.value");
  15. propKeyAgg.subAggregation(propValAgg);
  16. searchSourceBuilder.aggregation(level1Aggs);
  17. SearchRequest searchRequest = new SearchRequest();
  18. searchRequest.indices("smp-product");
  19. searchRequest.source(searchSourceBuilder);
  20. SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
  21. if(RestStatus.OK == searchResponse.status()){
  22. //查询结果
  23. SearchHits hits = searchResponse.getHits();
  24. log.info("hits={}",hits.getTotalHits());
  25. SearchHit[] arrs = hits.getHits();
  26. List<ESProduct> prods = new ArrayList<>(arrs.length);
  27. for(int i=0,len=arrs.length;i<len;i++){
  28. SearchHit hit = arrs[i];
  29. //ESProduct为商品类
  30. ESProduct prod = JSON.parseObject(hit.getSourceAsString(),ESProduct.class);
  31. prods.add(prod);
  32. }
  33. Aggregations aggregations = searchResponse.getAggregations();
  34. //聚合结果处理
  35. ParsedNested level1Agg = aggregations.get("level1Agg");
  36. Aggregations keyAggs = level1Agg.getAggregations();
  37. Terms byAgeAggregation = keyAggs.get("keyAggs");
  38. List<FilterParamsDto> params = new ArrayList<>();
  39. for(Terms.Bucket buck : byAgeAggregation.getBuckets()) {
  40. Aggregations valAggs = buck.getAggregations();
  41. Terms byValAggs = valAggs.get("valAggs");
  42. FilterParamsDto param = new FilterParamsDto();
  43. param.setName(buck.getKeyAsString());
  44. List<String> vals = new ArrayList<>();
  45. param.setFilters(vals);
  46. for(Terms.Bucket bk : byValAggs.getBuckets()){
  47. log.info("key: " + bk.getKeyAsString());
  48. vals.add(bk.getKeyAsString());
  49. }
  50. params.add(param);
  51. }
  52. }
  53. log.info("finish");
  54. }

上面程序对应的ESProduct类定义如下:

  1. @Getter
  2. @Setter
  3. @Document(indexName="smp-product",type="es-product",shards=3,replicas = 0)
  4. @Mapping(mappingPath="mapping/es-product.json")
  5. public class ESProduct extends BaseEntityMethods {
  6. @Field
  7. String id;
  8. /**
  9. * 商品名字
  10. */
  11. @Field(name="mainTitle")
  12. String mainTitle;
  13. @Field(name="subTitle")
  14. String subTitle;
  15. /**
  16. * 商品品牌
  17. */
  18. @Field(name="brandName")
  19. String brandName;
  20. /**
  21. * 一级类目名称
  22. */
  23. @JsonIgnore
  24. @Field(name="level1Category")
  25. String level1Category;
  26. /**
  27. * 二级类目名称
  28. */
  29. @JsonIgnore
  30. @Field(name="level2Category")
  31. String level2Category;
  32. /**
  33. * 三级类目名称
  34. */
  35. @JsonIgnore
  36. @Field(name="level3Category")
  37. String level3Category;
  38. /**
  39. * 聚合关键词使用
  40. */
  41. @Field(name="aggProperties")
  42. List<SearchProperty> aggProperties;
  43. /**
  44. * 检索使用
  45. */
  46. @Field(name="searchProperties")
  47. Map<String,String> searchProperties;
  48. }

PS:

1、本文使用的elasticsearch为6.8版本

发表评论

表情:
评论列表 (有 0 条评论,43人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Elasticsearch聚合

    一、聚合分析简介 1. ES聚合分析是什么? 聚合分析是数据库中重要的功能特性,完成对一个查询的数据集中(**解释:结果集类似于“关系型数据库”里的表**)数据...