Skip to content

Feedback: Vector search #1273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vguptaa45 opened this issue Mar 12, 2025 · 5 comments
Closed

Feedback: Vector search #1273

vguptaa45 opened this issue Mar 12, 2025 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@vguptaa45
Copy link

Not able to extract more than 10 documents in vector search. Tried replacing <top_k> multiple times with a higher number.

Page https://redis.io/docs/latest/develop/interact/search-and-query/query/vector-search

@dwdougherty dwdougherty self-assigned this Mar 12, 2025
@dwdougherty dwdougherty added the question Further information is requested label Mar 12, 2025
@dwdougherty
Copy link
Collaborator

Hello @vguptaa45. Thank you for reaching out. There was an internal discussion about this issue, and one of our developer leads suggests adding LIMIT 0 15 to your query, as the default number of returned results is limited to ten. Support will be able assist further.

@vguptaa45
Copy link
Author

Hi. Getting the following error:

"Vector search all failed: Syntax error at offset 49 near LIMIT"

Have i implemented it correctly:

` # 1. Convert query vector
query_vector_np = np.array(query_vector, dtype=np.float16)
logger.info(f"1. Query vector prepared: shape={query_vector_np.shape}")

        # 2. Prepare search query without company filter
        query = f'*=>[KNN {k} @vector $query_vector AS vector_score LIMIT 0 15]'
        logger.info(f"2. Search query: {query}")

        # 3. Execute search
        logger.info("3. Executing search...")
        raw_results = self.redis_client_binary.ft(self.index_name).search(
            Query(query)
                .return_fields("content", "metadata", "vector_score", "compressed")
                .dialect(2),
            {'query_vector': query_vector_np.tobytes()}
        )
        logger.info(f"4. Raw search results: {raw_results.total} matches")

`

@alonre24
Copy link
Contributor

Let me rephrase - to get the first 15 results using redis-py, you will have to use the following query structure:

Query(query)
                .return_fields("content", "metadata", "vector_score", "compressed").paging(0, 15)
                .dialect(2)

Let me know if it works for you @vguptaa45

@vguptaa45
Copy link
Author

That worked! Thanks you for the help.

Would appreciate if this is clearely added to the docs and the website.

Have a great day

@dwdougherty
Copy link
Collaborator

Noted. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants