Tambayoyin Bincike na asali a cikin Elasticsearch: Cikakken Jagora

Tambayar tushen maɓalli(Match Query)

Ana amfani da tambayar Match don nemo takaddun da ke ɗauke da takamaiman kalmomi. Zai dawo da takaddun da ke da aƙalla kalma ɗaya daidai.

Misali: Nemo samfura tare da sunan mai ɗauke da maɓalli laptop  a cikin products Index.

GET /products/_search  
{  
  "query": {  
    "match": {  
      "name": "laptop"  
    }  
  }  
}  

 

Dole ne Ya ƙunshi Duk Mahimman kalmomi(Match Phrase Query)

Tambayar Jumlar Match tana buƙatar duk mahimman kalmomin da ke cikin tambayar su bayyana a jere kuma a daidai tsari a cikin rubutun takarda.

Misali: Nemo samfura tare da bayanin mai ɗauke da kalmar HP laptop.

GET /products/_search  
{  
  "query": {  
    "match_phrase": {  
      "description": "HP laptop"  
    }  
  }  
}  

 

Dole ne Ya ƙunshi Gabaɗayan Gabaɗayan Jumloli(Match Phrase Prefix Query)

Tambayar Match Phrase Prefix ta yi kama da Match Phrase, amma yana ba da damar yin wani juzu'i na maɓalli na ƙarshe.

Misali: Nemo samfura tare da bayanin farawa da laptop.

GET /products/_search  
{  
  "query": {  
    "match_phrase_prefix": {  
      "description": "laptop"  
    }  
  }  
}  

 

Tambayoyi na tushen lokaci(Query)

Ana amfani da tambayar Term don bincika takardu tare da filin da ke da ainihin ƙima kamar yadda aka ƙayyade.

Misali: Nemo samfuran da category filin ke da darajar laptop.

GET /products/_search  
{  
  "query": {  
    "term": {  
      "category": "laptop"  
    }  
  }  
}  

 

Tambaya ta tushen kewayon(Range Query)

Tambayar Range tana taimakawa nemo takardu tare da ƙimar filin cikin kewayon kewayon.

Misali: Nemo samfura masu farashi tsakanin 500 zuwa 1000.

GET /products/_search  
{  
  "query": {  
    "range": {  
      "price": {  
        "gte": 500,  
        "lte": 1000  
      }  
    }  
  }  
}  

 

Tambaya Matsayin Wa'adi

Tambayoyin matakin wa'adi suna ba da damar neman takaddun bisa takamaiman yanayi kamar Daidai, Prefix, Range, Wildcard, da tambayoyin Fuzzy.

Misali: Nemo samfuran da sunan farawa laptop da farashi tsakanin 500 zuwa 1000.

GET /products/_search  
{  
  "query": {  
    "bool": {  
      "must": [  
        {  
          "prefix": {  
            "name": "laptop"  
          }  
        },  
        {  
          "range": {  
            "price": {  
              "gte": 500,  
              "lte": 1000  
            }  
          }  
        }  
      ]  
    }  
  }  
}  

 

Full-Text Tambaya

Full-Text Tambayoyi suna ba da damar bincika filayen rubutu ta amfani da algorithms nazarin rubutu don nemo kalmomi iri ɗaya ko ma'ana.

Misali: Nemo samfura masu bayanin da ke ɗauke da ko dai computer  ko laptop.

GET /products/_search  
{  
  "query": {  
    "match": {  
      "description": "computer laptop"  
    }  
  }  
}  

 

Tambayar Boolean

Boolean Tambayoyi suna ba da damar haɗa ƙananan tambayoyin da yawa tare da yanayin bincike daban-daban, kamar dole ne ya ƙunshi duka, dole ne ya ƙunshi aƙalla ɗaya, ko dole ne ya ƙunshi, don cimma madaidaicin sakamakon bincike.

Misali: Nemo samfura masu kasancewa category da laptop  farashi tsakanin 500 zuwa 1000.

GET /products/_search  
{  
  "query": {  
    "bool": {  
      "must": [  
        {  
          "term": {  
            "category": "laptop"  
          }  
        },  
        {  
          "range": {  
            "price": {  
              "gte": 500,  
              "lte": 1000  
            }  
          }  
        }  
      ]  
    }  
  }  
}  

 

Waɗannan su ne ainihin tambayoyin nema a cikin Elasticsearch, tare da misalan misalan kowane nau'in tambaya. Lokacin amfani da Elasticsearch, zaku iya haɗa waɗannan tambayoyin don bincika bayanai cikin sassauƙa da inganci.