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

Confused on index building #514

Open
gbradburn opened this issue Apr 22, 2022 · 0 comments
Open

Confused on index building #514

gbradburn opened this issue Apr 22, 2022 · 0 comments

Comments

@gbradburn
Copy link

Greetings,

I'm trying to replace our search implementation using lunr (previously using fuse.js).
Using this in angular I have an array of objects. To build the index I iterate through the array per the example:
` private initializeLunr(simplifiedFlatCourtList: ISimplifiedCourtList[]) {
this.lunrIndex = lunr(function () {
this.ref('pGuid')
// this.field('abbreviation')
// this.field('strippedAbbreviation')
this.field('pathName')
// this.field('courtKey')

        simplifiedFlatCourtList.forEach(function(court){
            this.add(court)
        }, this)
    })
}`

Here is an example of the data I'm trying to index:
[ { "pGuid": "urn:krm:pvi-460B269BFD3B4457A1C1D9EC2F5F7E47", "name": "United States", "pathName": "United States", "abbreviation": "U.S. Fed", "strippedAbbreviation": "US Fed", "displayName": "United States (All)" }, { "pGuid": "urn:entity:jb-100000366", "courtKey": "US_MDL_MDL", "pathName": "United States / Jud. Panel Multidistrict Litigation", "abbreviation": "J.P.M.L", "strippedAbbreviation": "JPML", "displayName": "United States / Jud. Panel Multidistrict Litigation" }]

We want to index by four fields but when I couldn't get that working I commented out 3 of them and just used the pathName field.
I have verified that pathName is populated for each of the entries in the array but when I search I get no results even when using a value that should be an exact match (e.g. 'United States'). Furthermore, when I examine the lunrIndex in the debugger it doesn't seem like it is including the pathName values anywhere.

I am also confused by the terminology. In the example it refers to "documents" but seems to use them in a context I would expect to be "records" or "rows". In other words, what they call a collection of "documents" seems to me to be a single document with several "rows" or "records".

Any idea what I'm doing wrong?

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

1 participant