【问题标题】:How to get document id in python search api?如何在 python 搜索 api 中获取文档 ID?
【发布时间】:2016-03-23 09:17:39
【问题描述】:

我正在使用带有 Python 语言的 Google App Engine 开发一个地图站点,并已使用 Search API 应用到我的站点 (https://cloud.google.com/appengine/training/fts_intro/lesson2)。将其放入索引后如何获取文档ID?我做了如下但没有得到doc_id:

fields = [
    search.TextField(name = 'userid', value = request.userid),
    search.NumberField(name = 'zoom', value = request.zoom),
    search.TextField(name = 'title', value = request.title),
    search.TextField(name = 'content', value = request.content),
    search.GeoField(name = 'location', value = search.GeoPoint(request.lat, request.lng))
]

d = search.Document(fields = fields)
search.Index(name = _INDEX_NAME).put(d)
doc_id = d.doc_id

【问题讨论】:

  • 您需要更具体一点。 你用的是什么“python搜索api”?
  • 谢谢丹尼尔,我刚刚编辑了我的问题。

标签: python api search


【解决方案1】:

full documentation

results = search.Index(name=_INDEX_NAME).put(d)
doc_id = results[0].id

【讨论】:

  • 非常感谢丹尼尔。
  • 我已接受您的回答。这是我第一次在这个网站上提问:)
猜你喜欢
  • 1970-01-01
  • 2020-10-11
  • 2018-05-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多