RediSearch / redisearch-py

RediSearch python client

Home Page:https://redisearch.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filter search by tags

laneme opened this issue · comments

commented

I have an index with a TagField, created like this

create_index([TextField("enc_id"), TextField("title", 2.0), TagField("tags")])

I would add a document like this.

add_document(title = "meh, lol", tags = "python,C")

I search like this. It has a few fields that don't need to be searched, so I limited fields to search.

Query(query_string='meh').limit_fields(title)

What I want is to also filter results by some tags. For example, I have documents with tags like python, C, Java and I only want documents to be returned that has the tag 'C'.

How do I do that?

commented

Okay found it.
I can use @ in the query string. Just like we do in cli.

Query("@title:meh @tags:{python}")