英文:
cosmos Point Read
问题
My cosmos db query
SELECT *
FROM c
WHERE c.id = "1437156155"
AND c.npi = 1437156155
npi is partition key
It is consuming 2.83 RUS
how to perform Point read so that it consume 1RU
sample document
{
    "npi": 1518966761,
    "Entity_Type_Code": "NA",
    "Employer Identification Number (EIN)": "NA",
    "Provider Last Name (Legal Name)": "NA",
    "Provider_First_Name": "NA",
    "Last Update Date": "NA",
    "NPI_Deactivation_Reason_Code": "NA",
    "NPI_Deactivation_Date": "03/20/2006",
    "NPI_Reactivation_Date": "NA",
    "Healthcare_Provider_Taxonomy_Group_1": "NA",
    "id": "1518966761"
}
I have to achieve this in python
index policy
{
    "indexingMode": "consistent",
    "automatic": true,
    "includedPaths": [
        {
            "path": "/*"
        }
    ],
    "excludedPaths": [
        {
            "path": "/\"_etag\"/?"
        }
    ]
}
Anything need to perform in index policy? I found below link it has example for dotnet, i am looking for python
https://devblogs.microsoft.com/cosmosdb/point-reads-versus-queries/
英文:
My cosmos db query
SELECT *
FROM c
WHERE c.id = "1437156155"
AND c.npi = 1437156155
npi is partition key
It is consuming 2.83 RUS
how to perform Point read so that it consume 1RU
sample document
    {
        "npi": 1518966761,
        "Entity_Type_Code": "NA",
        "Employer Identification Number (EIN)": "NA",
        "Provider Last Name (Legal Name)": "NA",
        "Provider_First_Name": "NA",
        "Last Update Date": "NA",
        "NPI_Deactivation_Reason_Code": "NA",
        "NPI_Deactivation_Date": "03/20/2006",
        "NPI_Reactivation_Date": "NA",
        "Healthcare_Provider_Taxonomy_Group_1": "NA",
        "id": "1518966761"
    }
I have to achieve this in python
index policy
    {
        "indexingMode": "consistent",
        "automatic": true,
        "includedPaths": [
            {
                "path": "/*"
            }
        ],
        "excludedPaths": [
            {
                "path": "/\"_etag\"/?"
            }
        ]
    }
Anything need to perform in index policy? I found below link it has example for dotnet, i am looking for python
https://devblogs.microsoft.com/cosmosdb/point-reads-versus-queries/
答案1
得分: 2
response = container.read_item(item="1437156155", partition_key="1437156155")
英文:
Reference: https://learn.microsoft.com/azure/cosmos-db/nosql/samples-python
response = container.read_item(item="1437156155", partition_key="1437156155")
答案2
得分: 1
"Looks like you are looking at the RUs consumed on the Data Explorer, Point operations need to be executed through the SDKs themselves, a query that filters by id and partition key is still considered a query.
Read using Python SDK as Matias mentioned above,
英文:
Looks like you are looking at the RUs consumed on the Data Explorer, Point operations need to be executed through the SDKs themselves, a query that filters by id and partition key is still considered a query.
Read using Python SDK as Matias mentioned above,
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论