Elasticsearch DSL语句学习

POST /reagent/_delete_by_query
{
  "query": {
    "match_all": {}
  }
}

DELETE /reagent

PUT /reagent
{
  "settings": {
    "analysis": {
      "char_filter": {
            "line":{
              "type":"mapping",
              "mappings":[
                  "-=>underline"
                ]
            }
        },
        "analyser": {
          "line":{
            "char_filter":"line",
            "tokenizer":"standard",
            "filter": ["lowercase"]
          }
        }
      }
    }
}

PUT /reagent
{
  "settings": {
    "analysis": {
      "analyzer": "ik_smart"
    }
  }
}

GET /reagent/_search?size=10000&from=0
{
  "query": {
    "match_all": {}
  }
}

GET /reagent/docs

GET /reagent/_search?size=2000&from=0
{
  "query": {
    "match": {
      "name": {
        "query": "α",
        "operator": "or",
        "analyzer": "standard"
      }
    }
  }
}

GET /reagent/_search
{
  "query": {
    "term": {
      "number": {
        "value": "H00001360-R01-20nmol"
      }
    }
  }
}

GET /reagent/_search?size=10000&from=0
{
  "query": {
    "match_phrase": {
      "name": {
        "query": "β1",
        "analyzer": "standard"
      }
    }
  }
}

GET /reagent/_search?size=10000&from=0
{
  "query": {
          "simple_query_string": {
            "fields": ["name","alias","number"], 
            "query":"β1",
            "analyzer": "standard"
          }
    }
}

GET _analyze
{
  "analyzer": "ik_smart",
  "text": "20S Proteasome β1 CRISPR/Cas9 KO Plasmid (m)"
}


GET /reagent/_analyze
{
  "analyzer": "standard", 
  "text": "20S Proteasome β1 CRISPR/Cas9 KO Plasmid (m)"
}

GET /reagent/docs/1847636

GET /reagent/docs/1847636/_termvectors?fields=name

GET /reagent/_search?size=10000&from=0
{
  "query": {
    "bool": {
      "should": [
        {
          "query_string": {
            "fields": ["name","alias","number"], 
            "query":"2,4,4-三甲基-1-戊烯" ,
            "analyzer": "my_analyzer",
            "minimum_should_match": "50%", 
            "boost": 5
          }
        },
        {
          "match": {
            "name": {
              "query": "2,4,4-三甲基-1-戊烯",
              "analyzer": "my_analyzer",
              "operator": "or",
              "minimum_should_match": "75%",
              "boost": 2
            }
          }
        },
        {
          "match": {
            "alias": {
              "query": "2,4,4-三甲基-1-戊烯",
              "analyzer": "my_analyzer",
              "operator": "or",
              "minimum_should_match": "75%",
              "boost": 1
            }
          }
        },
        {
          "match": {
            "number": {
              "query": "2,4,4-三甲基-1-戊烯",
              "analyzer": "my_analyzer",
              "operator": "or",
              "minimum_should_match": "75%",
              "boost": 1
            }
          }
        },
        {
          "match": {
            "name": {
              "query": "2,4,4-三甲基-1-戊烯",
              "analyzer": "standard",
              "operator": "or",
              "minimum_should_match": "75%",
              "boost": 2
            }
          }
        },
        {
          "match": {
            "alias": {
              "query": "2,4,4-三甲基-1-戊烯",
              "analyzer": "standard",
              "operator": "or",
              "minimum_should_match": "75%",
              "boost": 1
            }
          }
        },
        {
          "match": {
            "number": {
              "query": "2,4,4-三甲基-1-戊烯",
              "analyzer": "standard",
              "operator": "or",
              "minimum_should_match": "75%",
              "boost": 1
            }
          }
        },
        {
          "match_phrase_prefix": {
            "name": {
              "query": "2,4,4-三甲基-1-戊烯",
              "boost": 5
            }
          }
        },
        {
          "match_phrase_prefix": {
            "alias": {
              "query": "2,4,4-三甲基-1-戊烯",
              "boost": 5
            }
          }
        },
        {
          "match_phrase_prefix": {
            "number": {
              "query": "2,4,4-三甲基-1-戊烯",
              "boost": 5
            }
          }
        }
      ]
    }
  }
}

PUT /reagent
{
  "settings": {
    "analysis": {
      "char_filter": {
        "symbol":{
          "type":"mapping",
          "mappings":["-=>line","/=>italic","β=>beta","α=>alpha","γ=>gamma","δ=>delta","ε=>epsilon","ζ=>zeta","η=>eta","θ=>thet","ι=>iot","κ=>kappa","λ=>lambda","μ=>mu","ν=>nu","ξ=>xi","ο=>omicron","π=>pi","ρ=>rho","σ=>sigma","τ=>tau","υ=>upsilon","φ=>phi","χ=>chi","ψ=>psi","ω=>omega"]
        }
      },
      "analyzer": {
        "my_analyzer":{
          "type":"custom",
          "char_filter":["symbol"],
          "tokenizer":"ik_smart",
          "filter":["lowercase"]
        }
      }
    }
  },
  "mappings": {
    "docs": {
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "@version": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "alias": {
          "type": "text",
          "analyzer":"my_analyzer",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "company": {
          "type": "text",
          "analyzer":"my_analyzer",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "companyid": {
          "type": "long"
        },
        "createtime": {
          "type": "date"
        },
        "discount": {
          "type": "long"
        },
        "fromid": {
          "type": "long"
        },
        "id": {
          "type": "long"
        },
        "instruction": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "iscomplete": {
          "type": "long"
        },
        "isdelete": {
          "type": "long"
        },
        "kitsize": {
          "type": "float"
        },
        "kittype": {
          "type": "long"
        },
        "modifytime": {
          "type": "date"
        },
        "name": {
          "type": "text",
          "analyzer":"my_analyzer",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "number": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "price": {
          "type": "float"
        },
        "reagenttypeid": {
          "type": "long"
        },
        "remark": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "type": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "unit": {
          "type": "long"
        },
        "website": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "zone": {
          "type": "long"
        }
      }
    }
  }
}

猜你喜欢

转载自blog.csdn.net/weweeeeeeee/article/details/85051570