I have Documents that I'd like to make searchable in 3 different languages. Since I can have multiple fields with the same name/type, the following Document structure works (this is a simplified example).
document = search.Document(
fields=[
search.TextField(
name="name",
language="en",
value="dog"),
search.TextField(
name="name",
language="es",
value="perro"),
search.TextField(
name="name",
language="fr",
value="chien")
]
)
index = search.Index("my_index")
index.put(document)
Specifying the language helps Google tokenize the value of the TextField
.
The following queries all work, each returning one result:
print index.search("name: dog")
print index.search("name: perro")
print index.search("name: chien")
Here is my question: Can I restrict a search to only target fields with a specific language?
The purpose is to avoid getting false positive results. Since each language uses the Arabic alphabet, it's possible that someone performing a full text search in Spanish may see English results that are not relevant.
Thank you.
get_index(lang-detected).search(query)
or translating search term to stored data language and searching based on translation result – Unbolted