DocumentDb:查询没有索引 [英] DocumentDb: Querying without an index

查看:377
本文介绍了DocumentDb:查询没有索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在排除索引的所有路径,为什么我依然能够在领域执行成功的查询以外ID?

剔除所有路径:

  collection.IndexingPolicy.ExcludedPaths.Add(新ExcludedPath()
    {
        路径=/ *
    });

查询:

  SELECT * FROM C其中c.Key =117dfd49-a71d-413B-a9b1-841e88db06e8

这个MSDN文章:


  

<青霉>当索引被关闭时,文件可只通过其自身的链接或通过使用ID的查询访问​​。的


编辑:

当寻找到索引政策我看看我的路径不排除:

  {
  indexingMode:保持一致,
  自动:真实,
  includedPaths:[
    {
      路径:/ *,
      指标:
        {
          种:范围,
          数据类型:号码,
          precision:-1
        },
        {
          种:哈希
          数据类型:字符串,
          precision:3
        }
      ]
    },
    {
      路径:/ \\_ TS \\/?,
      指标:
        {
          种:范围,
          数据类型:号码,
          precision:-1
        },
        {
          种:哈希
          数据类型:字符串,
          precision:3
        }
      ]
    }
  ]
  excludedPaths:[]
}

我在做什么错了?

我使用一致的索引,所以肯定这是不是与索引传播最终一致性的问题,如果我理解正确吗?

下面是所有code:

  VAR collectionSpec =新DocumentCollection {ID = collectionId};
VAR requestOptions =新RequestOptions {OfferType =S1};集合= Client.CreateDocumentCollectionAsync(databaseLink,collectionSpec,requestOptions)。结果;collection.IndexingPolicy.IndexingMode = IndexingMode.Consistent;
collection.IndexingPolicy.ExcludedPaths.Add(新ExcludedPath()
    {
        路径=/ *
    });


解决方案

我看不到任何呼叫建立新的索引策略后更换文档集合。

您需要调用 Client.ReplaceDocumentCollectionAsync()有你的索引策略更改生效。

该方法文档<一个href=\"https://msdn.microsoft.com/en-us/library/azure/microsoft.azure.documents.client.documentclient.replacedocumentcollectionasync.aspx\"相对=nofollow>这里。

和这里的一篇文章写的DocumentDB团队对在线更新的索引策略(这是指需要调用 ReplaceDocumentCollectionAsync())。

When excluding all paths from indexing, how come I am still able to perform a successful query on fields other than ID?

Excluding all paths:

collection.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath()
    {
        Path = "/*"
    });

Query:

SELECT * FROM c where c.Key = "117dfd49-a71d-413b-a9b1-841e88db06e8"

Accordingly this MSDN article:

When indexing is turned off, documents can be accessed only through their self-links or by queries using ID.

EDIT:

When looking into the indexing policy I see what my paths aren't excluded:

{
  "indexingMode": "consistent",
  "automatic": true,
  "includedPaths": [
    {
      "path": "/*",
      "indexes": [
        {
          "kind": "Range",
          "dataType": "Number",
          "precision": -1
        },
        {
          "kind": "Hash",
          "dataType": "String",
          "precision": 3
        }
      ]
    },
    {
      "path": "/\"_ts\"/?",
      "indexes": [
        {
          "kind": "Range",
          "dataType": "Number",
          "precision": -1
        },
        {
          "kind": "Hash",
          "dataType": "String",
          "precision": 3
        }
      ]
    }
  ],
  "excludedPaths": []
}

What am I doing wrong?

I am using consistent indexing, so surely this is not an issue of eventual consistency with the index propagation, if I understand it correctly?

Here is all the code:

var collectionSpec = new DocumentCollection { Id = collectionId };
var requestOptions = new RequestOptions { OfferType = "S1" };

collection = Client.CreateDocumentCollectionAsync(databaseLink, collectionSpec, requestOptions).Result;

collection.IndexingPolicy.IndexingMode = IndexingMode.Consistent;
collection.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath()
    {
        Path = "/*"
    });

解决方案

I don't see any call to replace the document collection after setting up the new indexing policy.

You need to call Client.ReplaceDocumentCollectionAsync() to have your indexing policy changes take effect.

The method documentation is here.

And here's an article written by the DocumentDB team about updating index policies online (which refers to the need to call ReplaceDocumentCollectionAsync()).

这篇关于DocumentDb:查询没有索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆