Tablestore SDK for Go'da, bir Text alanındaki belirteçlerin sırasına ve konumuna dayalı olarak bir ifadeyle eşleşmek için match phrase sorgusu kullanın.
Ön koşullar
Tablestore Go SDK öğesini yükleyin ve bir istemci başlatın.
Açıklama
Match phrase sorgusu, sorgu metnini belirteçlere ayırır ve bu belirteçlerin bir Text alanında belirtilen sırada görünmesini gerektirir. Slop parametresi, belirteçlerin kapsayabileceği konum sayısını kontrol eder. Bir Text alanı bulanık analizör kullanıyorsa match phrase sorgusu, daha düşük gecikme süresiyle wildcard sorgusuna benzer bulanık eşleştirme sunabilir.
func (client *tablestore.TableStoreClient) Search(request *tablestore.SearchRequest) (*tablestore.SearchResponse, error)
Aşağıdaki örnekte veri sorgulanır ve en fazla 10 satır ile eşleşen toplam satır sayısı döndürülür.
tableName := "example_table"
indexName := "example_index"
query := &search.MatchPhraseQuery{FieldName: "title", Text: "go search", Slop: proto.Int32(0)}
searchQuery := search.NewSearchQuery().
SetQuery(query).
SetLimit(10).
SetGetTotalCount(true)
response, err := client.Search(&tablestore.SearchRequest{
TableName: tableName,
IndexName: indexName,
SearchQuery: searchQuery,
ColumnsToGet: &tablestore.ColumnsToGet{
ReturnAllFromIndex: true,
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(response.TotalCount)
fmt.Println(response.Rows)
Parametreler
Sorgu isteği
request parametresi tablestore.SearchRequest türündedir ve aşağıdaki parametreleri içerir.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sorgu yapılandırması
search.NewSearchQuery() çağrısıyla bir sorgu yapılandırması oluşturun ve aşağıdaki yöntemleri kullanarak yapılandırın.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sorgu koşulu
Sorgu search.MatchPhraseQuery türündedir ve aşağıdaki parametreleri içerir.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Döndürülecek sütunlar
request.ColumnsToGet parametresi tablestore.ColumnsToGet türündedir ve aşağıdaki parametreleri içerir.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Yanıt
Search yöntemi bir tablestore.SearchResponse değeri döndürür. Aşağıdaki tabloda temel iş alanları açıklanmaktadır.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|