Chameleon
Chameleon

Reputation: 10138

Google App Engine - Add search fields for multiple tags (adding multiple tags to search)?

I want use Search API but not know how to add multiple tags - it is not describe clearly.

Can I do such thing:

fields = []
for tag in self.tags:
  fields.append(search.TextField(name = 'tag', value = tag))

Or it need different approach since multiple 'tag' fields is not possible?

Upvotes: 0

Views: 216

Answers (2)

Nick
Nick

Reputation: 1822

You can whitespace concatenate all the tags into one text field.

If you're only interested in matching documents and don't require the tags to be structured as separate field, a query matching any tag will return the document as a match. This also helps when searching on multiple tags, because the document can have a higher relevance if it has both.

Upvotes: 1

Daniel Roseman
Daniel Roseman

Reputation: 599876

It is not true that "multiple tag fields is not possible". You can have multiple fields with the same name.

Upvotes: 3

Related Questions