Skip to content
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

How can i filter search based on specific fields #94

Open
marvinjude opened this issue Nov 22, 2018 · 1 comment
Open

How can i filter search based on specific fields #94

marvinjude opened this issue Nov 22, 2018 · 1 comment

Comments

@marvinjude
Copy link

marvinjude commented Nov 22, 2018

Nice Project, i am super excited!

in my gatsby, i am trying to search an index generated by @gatsby-contrib/elasticlunr, the generated index looks like this:

    {
     "version": "0.9.5",
     "fields": ["title", "path", "section"],
     "ref": "id",
     "documentStore": {
        "docs": {
            "fe565569-77a5-566d-bb47-96a6094c22c5": {
                "id": "fe565569-77a5-566d-bb47-96a6094c22c5",
                "title": "schema",
                "path": "/graphql/schema",
                "section": "graphql"
            },
            "cd1cdd40-4bb7-5ff6-9908-6c9ad692e75c": {
                "id": "cd1cdd40-4bb7-5ff6-9908-6c9ad692e75c",
                "title": "Component",
                "path": "/react/component",
                "section": "react"
            },
            "c1aecadb-3d1e-5d49-87f3-2b6f2c73433c": {
                "id": "c1aecadb-3d1e-5d49-87f3-2b6f2c73433c",
                "title": "Component",
                "path": "/react/component2",
                "section": "react"
            },
            "07159f12-dafb-53f6-b1ad-5032d56d25bb": {
                "id": "07159f12-dafb-53f6-b1ad-5032d56d25bb",
                "title": "Lazy",
                "path": "/react/suspense",
                "section": "react"
            },
            "380309db-ffa1-5f24-a192-36ac36b90a06": {
                "id": "380309db-ffa1-5f24-a192-36ac36b90a06",
                "title": "suspense",
                "path": "/react/lazy",
                "section": "react"
            },
           "380309db-ffa1-5f24-a192-36ac36b90uuuu": {
                "id": "380309db-ffa1-5f24-a192-36ac36b9uuuu",
                "title": "super",
                "path": "/graphql/super",
                "section": "graphql"
            }
        }
    }
   .....
}

is there a way i can get only get results whose section == react alone, and not all docs that match a search query in terms of a field.

e.g when i search with a term su with expand: true in the config and set a filter section = 'graphql' it should return :

  "380309db-ffa1-5f24-a192-36ac36b90uuuu": {
        "id": "380309db-ffa1-5f24-a192-36ac36b9uuuu",
        "title": "super",
        "path": "/graphql/super",
        "section": "graphql"
   }

but what i am currently getting is :

{
    "380309db-ffa1-5f24-a192-36ac36b90a06": {
        "id": "380309db-ffa1-5f24-a192-36ac36b90a06",
        "title": "suspense",
        "path": "/react/lazy",
        "section": "react"
    },
    "380309db-ffa1-5f24-a192-36ac36b90uuuu": {
        "id": "380309db-ffa1-5f24-a192-36ac36b9uuuu",
        "title": "super",
        "path": "/graphql/super",
        "section": "graphql"
    }
}

Thanks!

@congilitymark
Copy link

Hi @marvinjude. I'm considering using Elasticlunr and would be interested if you found a solution to this post. I have a similar requirement.
Cheers Mark

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

No branches or pull requests

2 participants