Google App Engine - Using Search API Python with list fields

前端 未结 2 720
日久生厌
日久生厌 2021-02-15 23:45

I\'m using ndb.Model. The Search API has the following field classes:

    TextField : plain text
    HtmlField : HTML formatted text
    AtomField : a string wh         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-16 00:30

    You should add as many fields as 'tags' you have, all with the same field_name:

    doc = search.Document(fields=[
        search.TextField(name='tag', value=t) for t in tags
    ])
    

    As in the docs:

    A field can contain only one value, which must match the field's type. Field names do not have to be unique. A document can have multiple fields with the same name and same type, which is a way to represent a field with multiple values. (However, date and number fields with the same name can't be repeated.) A document can also contain multiple fields with the same name and different field types.

提交回复
热议问题