Tüm Ürünler
Search
Belge Merkezi

Tablestore:İç içe geçmiş sorgu gerçekleştirme

Son Güncelleme:Oct 02, 2026

Bu konuda, iç içe geçmiş sütunların alt satırlarındaki verileri sorgulamak için iç içe geçmiş sorguların nasıl yapılacağı açıklanmaktadır. İç içe geçmiş bir sütunu sorgulamadan önce NestedQuery işlemiyle sarmalamanız gerekir. NestedQuery işlemini çağırırken herhangi bir türde bir alt sorgu ve iç içe geçmiş sütunun yolunu belirtin.

Önkoşullar

Parametreler

Parametre

Açıklama

Path

İç içe geçmiş sütunun yolu. Yol, ağaç yapısına benzer. Örneğin, news.title, iç içe geçmiş türdeki news sütunundaki title alt sütununu gösterir.

Query

İç içe geçmiş sütundaki alt sütun üzerindeki sorgu. Sorgu herhangi bir sorgu türünde olabilir.

ScoreMode

Sütun birden çok değer içerdiğinde puanın hesaplanması için hangi değerin kullanılacağını belirtir.

TableName

Veri tablosunun adı.

IndexName

Arama dizininin adı.

ColumnsToGet

Sorgu koşullarını karşılayan satırlardaki tüm sütunların döndürülüp döndürülmeyeceğini belirtir. ReturnAll, Columns ve ReturnAllFromIndex parametrelerini belirtebilirsiniz.

Varsayılan olarak ReturnAll değeri false olur; bu durumda yalnızca birincil anahtar sütunları döndürülür. Ek sütunlar döndürmek için aşağıdaki seçeneklerden birini kullanın:

  • Döndürülecek sütunları belirtmek için Columns değerini ayarlayın.

  • Arama dizinindeki tüm sütunları döndürmek için ReturnAllFromIndex değerini true olarak ayarlayın.

Veri tablosundaki tüm sütunları döndürmek için ReturnAll değerini true olarak ayarlayın.

Örnek

Aşağıdaki örnek kod, col_nested sütunundaki nested_1 alt sütununun değeri "tablestore" olan satırların nasıl sorgulanacağını gösterir. Arama dizinindeki tüm sütunlar döndürülür.

/// <summary>
/// Query the rows in which the value of the col1_nested.nested_1 column is "tablestore". In this example, the col1_nested column is a nested column and contains the nested_1 and nested_2 subcolumns. 
/// </summary>
/// <param name="otsClient"></param>
public static void NestedQuery(OTSClient otsClient)
{
    var searchQuery = new SearchQuery();
    // Return the total number of rows that meet the query conditions. 
    searchQuery.GetTotalCount = true;
    var nestedQuery = new NestedQuery();
    nestedQuery.Path = "col1_nested"; // Specify the path of the nested column. 
    TermQuery termQuery = new TermQuery("col1_nested.nested_1",new ColumnValue("tablestore"));// Construct a subquery of for the nested query. 
    nestedQuery.Query = termQuery;
    nestedQuery.ScoreMode = ScoreMode.None;

    var request = new SearchRequest(TableName, IndexName, searchQuery);
    // You can specify the ColumnsToGet parameter to return the columns that you specify, all columns in the rows that meet the query conditions, or all columns in the search index. If you do not specify this parameter, only the primary key columns are returned. 
    request.ColumnsToGet = new ColumnsToGet()
    {
        // Return all columns in the search index. 
        ReturnAllFromIndex = true
        // Return the columns that you specify. 
        //Columns = new List<string>() { Long_type_col, Text_type_col, Keyword_type_col }
        // Return all columns in the rows that meet the query conditions. 
        //ReturnAll = true
    };

    var response = otsClient.Search(request);

    Console.WriteLine("Total Count:" + response.TotalCount); // Display the total number of rows that meet the query conditions instead of the number of returned rows. 
}

SSS

Başvurular