Git Product home page Git Product logo

Comments (5)

kishorenc avatar kishorenc commented on May 24, 2024 5

Yes we have plans to implement this, it's already on our roadmap for join.

from typesense.

gravy-jones-locker avatar gravy-jones-locker commented on May 24, 2024 3

+1 for this feature. it would be incredibly helpful for us to avoid the kind of duplication mentioned by the OP - but I guess there were good reasons for not including it with the join work... @kishorenc are there any existing plans to implement this?

from typesense.

philefstat avatar philefstat commented on May 24, 2024 1

this would be awesome!

from typesense.

abiudmani avatar abiudmani commented on May 24, 2024

Hi @Napam I believe this can be achieved using the "filter_by" field instead of the "q" field in the query to search using the author name from the books collection itself as follows,

Query:
curl "http://localhost:8108/multi_search" -X POST
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}"
-d '{
"searches": [
{
"q": "*",
"collection": "books",
"include_fields": "$authors(first_name,last_name)",
"filter_by": "$authors(first_name:enid&&last_name:blyton)"
}
]
}'

Response:

{
"facet_counts": [],
"found": 2,
"hits": [
{
"document": {
"author_id": "1",
"authors": {
"first_name": "Enid",
"last_name": "Blyton"
},
"id": "2",
"title": "The Island of Adventure"
},
"highlight": {},
"highlights": []
},
{
"document": {
"author_id": "1",
"authors": {
"first_name": "Enid",
"last_name": "Blyton"
},
"id": "1",
"title": "The Mountain"
},
"highlight": {},
"highlights": []
}
],
"out_of": 10,
"page": 1,
"request_params": {
"collection_name": "books",
"first_q": "",
"per_page": 10,
"q": "
"
},
"search_cutoff": false,
"search_time_ms": 0
}

from typesense.

Napam avatar Napam commented on May 24, 2024

Hi @Napam I believe this can be achieved using the "filter_by" field instead of the "q" field in the query to search using the author name from the books collection itself as follows,

Query:

curl "http://localhost:8108/multi_search" -X POST -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{ "searches": [ { "q": "*", "collection": "books", "include_fields": "$authors(first_name,last_name)", **"filter_by": "$authors(first_name:enid&&last_name:blyton)"** } ] }'

Response:

{ "facet_counts": [], "found": 2, "hits": [ { "document": { "author_id": "1", "authors": { "first_name": "Enid", "last_name": "Blyton" }, "id": "2", "title": "The Island of Adventure" }, "highlight": {}, "highlights": [] }, { "document": { "author_id": "1", "authors": { "first_name": "Enid", "last_name": "Blyton" }, "id": "1", "title": "The Mountain" }, "highlight": {}, "highlights": [] } ], "out_of": 10, "page": 1, "request_params": { "collection_name": "books", "first_q": "_", "per_page": 10, "q": "_" }, "search_cutoff": false, "search_time_ms": 0 }

Hi @abiudmani, thanks for the tip, but this solution won't work in the context of simple search bar. Using a simple search bar we won't directly specify who the author is, we just want to search "enid", and it should just figure out all the books written by Enid.

Also, using the filter_by is not typo tolerant. You need to match exactly, which again is not what we want in a general search bar. E.g. I want to be able to go to the "Books" page and straight up search "enad bliton" (notice the typos) and I should get all books authored by "Enid Blyton".

from typesense.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.