ElasticSearch常用命令

GET _search
{
  "query": {
    "match_all": {}
  }
}

GET sharestock/_search
{
  "query": {
    "match_all": {}
  }
}

GET sharestock/_mapping?pretty
GET product/_mapping?pretty


GET product/_search
{
    "query": {
        "match": {
            "StandBrand": "ON Semiconductor"
        }
    }
}

GET product/_search
{
    "query": {
        "match": {
            "PartNo": "SDWL1005C2N8SSTFM01"
        }
    }
}

GET product/_search
{
    "query": {
      "bool":{
        "should":[
          {
             "match": {
                "PartNo": "RC0603FR-070R5L"
             }
          }
        ]
      }
    }
}

GET product/_search
{
  "query" : {
    "bool" : {
      "filter" : {
        "terms" : {
          "PartNo.keyword" : ["SI2333","SI2333CDS-T1-GE3","SI2333DDS-T1-GE3","SI2333CDS-T1-E3","SI2333-TP","SI2333DS-T1-GE3","SI2333DS-T1-E3"]
        }
      }
    }
  }
}

GET product/_search
{
  "size":50,
    "query": {
    "bool": {
     "must": [
       {
         "bool":{
        "should":[
          {
             "match": {
                "PartNo": "0402WGJ0121TCE"
             }
          },
          {
             "match": {
                "PartNo": "0402WGF1200TCE"
             }
          }
        ]
      }
       }
     ]
    }
  },
  "sort":{
    "SourceType":{"order":"asc"},
    "ID":{"order":"asc"}
  }
}

GET product/_search
{
  "size":50,
    "query": {
    "bool": {
     "must": [
       {
         "bool":{
            "should":[
              {
                 "term": {
                    "PackageType" : "5025"
                 }
              }
            ]
          }
       }
     ]
    }
  }
}

GET product/_search
{
   "query" : {
        "bool" : {
          "should":[
            {
              "term":{
                "MaxOffset" : 1
              }
            }
          ],
          "must" : [
                        {
                          "term" : {"Category":1}
                        },
                        { 
                          "term" : { "PackageType.keyword" : "0402"}
                        }, 
                        { 
                          "term" : { "Resistance": 120 }
                        },
                        { 
                          "term" : { "Power": 0.0625 }
                        },
                        {
                            "terms":{
                                "CatetoryID":[
                                    "21"
                                ]
                            }
                        }
                    ]
       }
  }
}

GET product/_search
{
    "query": {
        "match": {
            "ExtendInfo" : "Chip capacitor        Chipcapacitor  贴片电容   阻容"
        }
    }
}

GET product/_search
{
    "query" : {
        "term" : { "Category" : 2 }
    },
    "sort" : {
        "_script" : {
            "type" : "number",
            "script" : {
                "lang": "painless",
                "source": "params.brand.indexOf(doc['StandBrand.keyword'].value)==-1?99:params.brand.indexOf(doc['StandBrand.keyword'].value)",
                "params" : {
                    "brand" : ["HARTING","FH"]
                }
            },
            "order" : "asc"
        }
    }
}

GET product/_search
{
  "from" : 0, "size" : 200,
    "query": {
      "bool": {
        "must" : [
                        {
                          "term" : {"Category":1}
                        },
                        { 
                          "term" : { "Power" : 0.25}
                        }, 
                        { 
                          "term" : { "Resistance": 5100.0 }
                        },
                        {
                            "terms":{
                                "CatetoryID":[
                                    "31"
                                ]
                            }
                        }
                    ],
        "should":[
          { 
                "term" : { "MaxOffset" : 105}
          },
          {
            "term":{"FrequencyTolerance" : 50.0}
          }
        ]
        
      }
    }
}

GET product/_search
{
  "from" : 0, "size" : 100,
    "query": {
      "bool": {
        "must" : [
                        { 
                          "term" : { "Size.keyword": "10×1"}
                        }
                    ]
        
      }
    }
}



GET sharestock/_search
{
    "query": {
        "match": {
            "Model" : "DF22-3P-7.92DS(05)"
        }
    }
}

GET sharestock/_search
{
    "query": {
        "match": {
            "Model" : "LM358"
        }
    }
}

GET sharestock/_search
{
  "from" : 0, "size" : 10,
    "query": {
      "bool": {
        "must" : [
                        { 
                          "term" : { "StandMakeYear.keyword": "2012+"}
                        }
                    ]
        
      }
    }
}

PUT sharestock/_mapping
{
  "properties": {
    "StandMakeYear" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }
  }
}


GET sharestock/_search
{
    "query": {
        "match": {
            "ShareGuid": "454997b6-f92f-44d0-92dd-bd0fd6c67f15"
        }
    }
}

POST sharestock/_delete_by_query
{
    "query": {
        "match": {
            "OpenId": "bb10b4b8-3efb-4fce-a4a2-eaaaa9b99933"
        }
    }
}

GET sharestock/_search
{
    "query": {
    "bool": {
     "must": [
       {
         "match": {
            "Model": {"query" : "MOC3041M"}
         }
       },
       {
         "match": {
            "StandBrand": {"query" : "ON","analyzer" : "standard"}
         }
       }
     ]
    }
  }
}

GET sharestock/_search
{
    "query": {
    "bool": {
     "must": [
       {
         "match": {
            "Model": {"query" : "MMBT4401"}
         }
       },
       {
         "match": {
            "StandBrand": {"query" : "ON"}
         }
       }
     ]
    }
  }
}

GET sharestock/_search
{
    "query": {
    "bool": {
     "must": [
       {
         "term": {
            "Model.keyword":"MMBT4401"
         }
       }
     ]
    }
  }
}

GET sharestock/_search
{
    "query": {
    "bool": {
     "must": [
       {
         "term": {
            "SupplierName":"立创"
         }
       }
     ]
    }
  }
}

GET sharestock/_search
{
  "query" : {
    "bool" : {
      "filter" : {
        "term" : {
          "Model.keyword": "LM3582N4920"
        }
      }
    }
  }
}

GET sharestock/_search
{
  "query" : {
    "bool" : {
      "filter" : {
        "terms" : {
          "Model.keyword" : ["MMBT4401LT1G","SI2333CDS-T1-GE3","SI2333DDS-T1-GE3","SI2333CDS-T1-E3","SI2333-TP","SI2333DS-T1-GE3","SI2333DS-T1-E3"]
        }
      }
    }
  }
}

GET sharestock/_search
{
    "query": {
    "bool": {
     "must": [
       {
         "match": {
            "StandBrand": {"query" : "on","analyzer" : "standard"}
         }
       }
     ]
    }
  }
}

GET sharestock/_search
{
  "from" : 0, "size" : 100,
    "query": {
      "bool": {
        "must" : [
                        {
                            "terms":{
                                "ShareGuid":[
                                    "284ba610-5fce-495e-b6a4-99948054ef49","LM358HIP6005CB"
                                ]
                            }
                        }
                    ]
        
      }
    }
}

GET /_analyze
{
  "analyzer" : "znl_smart",
  "text" : "245806024112829+"
}

GET /_cat/thread_pool

PUT sharestock
{
      "mappings" : {
      "essharestockproduct" : {
        "properties" : {
          "Brand" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "Capacitance" : {
            "type" : "float"
          },
          "CapacitorMaterial" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "Category" : {
            "type" : "long"
          },
          "CreateTime" : {
            "type" : "long"
          },
          "Electricity" : {
            "type" : "float"
          },
          "ExtendInfo" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "Frequency" : {
            "type" : "float"
          },
          "FrequencyTolerance" : {
            "type" : "float"
          },
          "Inductance" : {
            "type" : "float"
          },
          "IsInvoice" : {
            "type" : "boolean"
          },
          "Leadtime" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "Length" : {
            "type" : "float"
          },
          "Lifetime" : {
            "type" : "float"
          },
          "MOQ" : {
            "type" : "long"
          },
          "MakeYear" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "MaxOffset" : {
            "type" : "float"
          },
          "MaxTemperature" : {
            "type" : "float"
          },
          "MinOffset" : {
            "type" : "float"
          },
          "MinTemperature" : {
            "type" : "float"
          },
          "Model" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "OpenId" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "PackageType" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "Packaging" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "PlugInCrystal" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "Power" : {
            "type" : "float"
          },
          "Resistance" : {
            "type" : "float"
          },
          "SMD" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "ShareGrade" : {
            "type" : "long"
          },
          "ShareGuid" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "ShareQty" : {
            "type" : "long"
          },
          "StandBrand" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "StandMakeYear" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "StepPrice" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "StockType" : {
            "type" : "long"
          },
          "SupplierName" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "UpdateTime" : {
            "type" : "long"
          },
          "Voltage" : {
            "type" : "float"
          },
          "Weight" : {
            "type" : "float"
          }
        }
      }
    }
}

GET sharestock2/_mapping
DELETE sharestock

GET sharestock/_mapping

1 Reply to “ElasticSearch常用命令”

发表评论

邮箱地址不会被公开。