cosmos Point Read

huangapple go评论97阅读模式
英文:

cosmos Point Read

问题

My cosmos db query

  1. SELECT *
  2. FROM c
  3. WHERE c.id = "1437156155"
  4. 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

  1. {
  2. "npi": 1518966761,
  3. "Entity_Type_Code": "NA",
  4. "Employer Identification Number (EIN)": "NA",
  5. "Provider Last Name (Legal Name)": "NA",
  6. "Provider_First_Name": "NA",
  7. "Last Update Date": "NA",
  8. "NPI_Deactivation_Reason_Code": "NA",
  9. "NPI_Deactivation_Date": "03/20/2006",
  10. "NPI_Reactivation_Date": "NA",
  11. "Healthcare_Provider_Taxonomy_Group_1": "NA",
  12. "id": "1518966761"
  13. }

I have to achieve this in python

index policy

  1. {
  2. "indexingMode": "consistent",
  3. "automatic": true,
  4. "includedPaths": [
  5. {
  6. "path": "/*"
  7. }
  8. ],
  9. "excludedPaths": [
  10. {
  11. "path": "/\"_etag\"/?"
  12. }
  13. ]
  14. }

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

  1. SELECT *
  2. FROM c
  3. WHERE c.id = "1437156155"
  4. 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

  1. {
  2. "npi": 1518966761,
  3. "Entity_Type_Code": "NA",
  4. "Employer Identification Number (EIN)": "NA",
  5. "Provider Last Name (Legal Name)": "NA",
  6. "Provider_First_Name": "NA",
  7. "Last Update Date": "NA",
  8. "NPI_Deactivation_Reason_Code": "NA",
  9. "NPI_Deactivation_Date": "03/20/2006",
  10. "NPI_Reactivation_Date": "NA",
  11. "Healthcare_Provider_Taxonomy_Group_1": "NA",
  12. "id": "1518966761"
  13. }

I have to achieve this in python

index policy

  1. {
  2. "indexingMode": "consistent",
  3. "automatic": true,
  4. "includedPaths": [
  5. {
  6. "path": "/*"
  7. }
  8. ],
  9. "excludedPaths": [
  10. {
  11. "path": "/\"_etag\"/?"
  12. }
  13. ]
  14. }

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

  1. response = container.read_item(item="1437156155", partition_key="1437156155")
英文:

Reference: https://learn.microsoft.com/azure/cosmos-db/nosql/samples-python

  1. 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,

huangapple
  • 本文由 发表于 2023年4月13日 23:36:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76007316.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定