I am currently using the Pattern Analyzer, but I found out that the result is wrong. I don't understand why?


(zzalyp) #1

1
2


(David Pilato) #2

Please don't post images of text as they are hardly readable and not searchable.

Instead paste the text and format it with </> icon. Check the preview window.


(zzalyp) #3
{
      "settings": {
        "number_of_replicas": 0,
        "analysis": {
          "analyzer": {
            "douhao": {
              "pattern": ",",
              "type": "pattern"
            },
            "merit_pro_code": {
              "type": "pattern",
              "pattern": "(\\w+)_",
              "lowercase": true
            },
            "merit_pro_time": {
              "type": "pattern",
              "pattern": "\\w+(?<=_)",
              "lowercase": true
            }
          }
        }
      },
      "mappings": {
        "product_info": {
          "properties": {
            "cust_id": {
              "type": "string"
            },
            "pro": {
              "type": "string",
              "analyzer": "douhao",
              "fields": {
                "code": {
                  "type": "string",
                  "analyzer": "merit_pro_code"
                },
                "time": {
                  "type": "string",
                  "analyzer": "merit_pro_time"
                }
              }
            }
          }
        }
      }
    }

(zzalyp) #4

Ok, thank you for your reminder.


(zzalyp) #5
{
  "query": {
    "bool": {
      "must": [
        {
          "prefix": {
            "pro": "b"
          }
        },
        {
          "range": {
            "pro.time": {
              "gte": "20180301",
              "lte": "20180301"
            }
          }
        }
      ]
    }
  }
}

(David Pilato) #6

So what is wrong?

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.


(zzalyp) #7

I want to view the data containing the b product, and the time range is on the day of March 1st, and the result of this product b is April.


(zzalyp) #8

The version of elasticsearch used in our project is 2.3.4,
Why are the following screening results 2 instead of 3?
Below is my complete query statement

{
  "query": {
    "bool": {
      "must": [
        {
          "prefix": {
            "pro": "b"
          }
        },
        {
          "range": {
            "pro.time": {
              "gte": "20180201",
              "lte": "20180201"
            }
          }
        }
      ]
    }
  }
}

index info

{
  "settings": {
    "number_of_replicas": 0,
    "analysis": {
      "analyzer": {
        "douhao": {
          "pattern": ",",
          "type": "pattern"
        },
        "merit_pro_code": {
          "type": "pattern",
          "pattern": "(\\w+)_",
          "lowercase": true
        },
        "merit_pro_time": {
          "type": "pattern",
          "pattern": "\\w+(?<=_)",
          "lowercase": true
        }
      }
    }
  },
  "mappings": {
    "product_info": {
      "properties": {
        "cust_id": {
          "type": "string"
        },
        "pro": {
          "type": "string",
          "analyzer": "douhao",
          "fields": {
            "code": {
              "type": "string",
              "analyzer": "merit_pro_code"
            },
            "time": {
              "type": "string",
              "analyzer": "merit_pro_time"
            }
          }
        }
      }
    }
  }
}

(David Pilato) #9

Please don't post images of text as they are hardly readable and not searchable.

Instead paste the text and format it with </> icon. Check the preview window. Please update your post.

Again, provide a full recreation script as described before. And update your version to latest when testing.


(system) #10

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.