Focus on big data and container cloud core technology decryption, can provide full stack of big data + cloud native platform consulting solutions, please continue to pay attention to this set of blog. If you have any academic exchange, please feel free to contact me. For more content, please pay attention to the public account of Data Cloud Technology Community.

1 Prefix Search

  • Prefix Query does not calculate relevance score. The only difference with prefix filter is that filters cache bitsets. The shorter the prefix, the more doc to process and the worse the performance. Use long prefixes whenever possible
GET my_index/my_type/_search
{
  "query": {
    "prefix": {
      "title": {
        "value": "C3"}}}} prefix search, how does it work? Why is the performance poor? Match c3-d0-kd345 c3-k5-dfg65 c3-i8-ui365 C doc1, C doc2 d0 kd345 k5 dfg65 c4 i8 UI365 C doc1, C doc2 d0 kd345 k5 dfg65 c4 i8 UI365 There is no need to continue searching for other terms: C3-k5-dfg65, and there may be many other strings with a prefix c3 --> You can't stop scanning c3-d0-kd345 for a term with a prefix c3. The search must continue until the entire inverted index has been scannedCopy the code
  • In actual scenarios, there may be some scenarios that full-text retrieval cannot solve
C3d0-kd345 c3k5-dfg65 c4i8-ui365 C3D0 KD345 c3 --> match --> match Obviously not. So: prefix matches c3 --> only prefix can be usedCopy the code

2 Wildcard search

  • Similar to prefix search, it’s much more powerful
[0-9] : numbers in a specified range [A-z] : letters in a specified range. : one character + : The preceding regular expression can appear once or more. GET my_index/my_type/_search {"query": {
    "wildcard": {
      "title": {
        "value": "C? K*5"}}}}Copy the code

3. Regular Search

GET /my_index/my_type/_search 
{
  "query": {
    "regexp": {
      "title": "C[0-9].+"}}}Copy the code

4 summarizes

Keep notes for easy reference.

Focus on big data and container cloud core technology decryption, can provide full stack of big data + cloud native platform consulting solutions, please continue to pay attention to this set of blog. If you have any academic exchange, please feel free to contact me. For more content, please pay attention to the public account of Data Cloud Technology Community.