Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. POST /analyzer_index
  2. {
  3. "settings": {
  4. "index": {
  5. "analysis": {
  6. "analyzer":{
  7. "myCustomAnalyzer":{
  8. "type":"custom",
  9. "tokenizer":"myCustomTokenizer",
  10. "filter":["myCustomFilter1","myCustomFilter2"],
  11. "char_filter":["myCustomCharFilter"]
  12. }
  13. },
  14. "tokenizer":{
  15. "myCustomTokenizer":{
  16. "type":"letter"
  17. }
  18. },
  19. "filter":{
  20. "myCustomFilter1":{
  21. "type":"lowercase"
  22. },
  23. "myCustomFilter2":{
  24. "type":"kstem"
  25. }
  26. },
  27. "char_filter":{
  28. "myCustomCharFilter":{
  29. "type":"mapping",
  30. "mappings":["jingdong=>jd","360buy=>jd"]
  31. }
  32. }
  33. }
  34. }
  35. },
  36. "mappings":{
  37. "analyzer_type":{
  38. "properties":{
  39. "description":{
  40. "type":"string",
  41. "analyzer":"myCustomAnalyzer"
  42. }
  43. }
  44. }
  45. }
  46. }
  47.  
  48.  
  49. POST /analyzer_index
  50. {
  51. "settings": {
  52. "index": {
  53. "analysis": {
  54. "analyzer":{
  55. "myCustomAnalyzer":{
  56. "type":"custom",
  57. "tokenizer":"myCustomTokenizer",
  58. "filter":["myCustomFilter2"],
  59. "char_filter":["myCustomCharFilter"]
  60. }
  61. },
  62. "tokenizer":{
  63. "myCustomTokenizer":{
  64. "type":"letter"
  65. }
  66. },
  67. "filter":{
  68. "myCustomFilter2":{
  69. "type":"kstem"
  70. }
  71. },
  72. "char_filter":{
  73. "myCustomCharFilter":{
  74. "type":"mapping",
  75. "mappings":["jingdong=>jd","360buy=>jd"]
  76. }
  77. }
  78. }
  79. }
  80. },
  81. "mappings":{
  82. "analyzer_type":{
  83. "properties":{
  84. "description":{
  85. "type":"string",
  86. "analyzer":"myCustomAnalyzer"
  87. }
  88. }
  89. }
  90. }
  91. }
  92.  
  93. GET analyzer_index/_mapping
  94.  
  95. DELETE /analyzer_index
  96. POST /analyzer_index/analyzer_type/_bulk
  97. {"index":{"_id":"1"}}
  98. {"description":"go shopping go 360buy"}
  99. {"index":{"_id":"2"}}
  100. {"description":"Go shopping go jingdong"}
  101. {"index":{"_id":"3"}}
  102. {"description":"go shopping go jd"}
  103. {"index":{"_id":"4"}}
  104. {"description":"go shopping"}
  105.  
  106.  
  107. GET /analyzer_index/analyzer_type/_search
  108.  
  109. GET /analyzer_index/analyzer_type/_search
  110. {
  111. "query": {
  112. "match": {
  113. "description": "jd"
  114. }
  115. }
  116. }
  117.  
  118. ##analyze text to token
  119. #based on custom
  120. GET _analyze
  121. {
  122. "analyzer":"standard",
  123. "text":"go shopping for 360buy jd"
  124. }
  125.  
  126. GET _analyze
  127. {
  128. "tokenizer":"whitespace",
  129. "filters":["lowercase","reverse"],
  130. "text":"share your experience with NoSql & big data technologies"
  131. }
  132. #based on a analyzer of index
  133. GET /analyzer_index/_analyze
  134. {
  135. "analyzer":"myCustomAnalyzer",
  136. "text":"go shopping go jd"
  137. }
  138. #based on a filed
  139. GET /analyzer_index/_analyze
  140. {
  141. "field":"description",
  142. "text":"go shopping go 360buy"
  143. }
  144.  
  145. #retrive term of document with id
  146. GET /analyzer_index/analyzer_type/1/_termvectors
  147. {
  148. "fields" : ["description"],
  149. "offsets" : true,
  150. "payloads" : true,
  151. "positions" : true,
  152. "term_statistics" : true,
  153. "field_statistics" : true
  154. }
  155. #why a document did not match
  156. POST /analyzer_index/analyzer_type/1/_explain
  157. {
  158. "query": {
  159. "match": {
  160. "description": "jd"
  161. }
  162. }
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement