Go için Tablestore SDK'da tam bir alan değeri veya belirteçle eşleşmek üzere term sorgusu kullanın.
Önkoşullar
Tablestore Go SDK bileşenini yükleyin ve bir istemci başlatın.
Açıklama
Term sorgusu, sorgu değeriyle tamamen eşit olan içeriği bulur. Keyword ve Long gibi metin dışı alanlarda alan değerinin sorgu değeriyle birebir aynı olması gerekir. Text alanlarında ise sorgu değeri kendisi tokenize edilmez; ancak alan içindeki herhangi bir belirteç sorgu değeriyle tam eşleşiyorsa bu bir eşleşme olarak kabul edilir. Daha fazla bilgi için bkz. Dize türleri.
func (client *tablestore.TableStoreClient) Search(request *tablestore.SearchRequest) (*tablestore.SearchResponse, error)
Aşağıdaki örnekte veriler 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.TermQuery{FieldName: "category", Term: "books"}
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() yöntemini çağırarak bir sorgu yapılandırması oluşturun ve aşağıdaki yöntemleri kullanarak yapılandırmayı ayarlayın.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sorgu koşulu
Sorgu search.TermQuery 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|