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

Querying returns no results? #14

Closed
miyachan opened this issue Aug 27, 2021 · 5 comments · Fixed by #15
Closed

Querying returns no results? #14

miyachan opened this issue Aug 27, 2021 · 5 comments · Fixed by #15
Labels
bug Something isn't working question Further information is requested

Comments

@miyachan
Copy link

I can't seem to get any results from lnx. I'm using commit e9804944edc8a7c0af24ee3ba8397b87f1640b5f. I built lnx using cargo build --release, then starting it with /usr/local/bin/lnx -p 4040.

# cat a.json
{
  "name": "my-index",
  "writer_buffer": 6000000,
  "writer_threads": 1,
  "reader_threads": 1,
  "max_concurrency": 10,
  "search_fields": [
    "title"
  ],
  "storage_type": "memory",
  "use_fast_fuzzy": true,
  "strip_stop_words": true,
  "fields": {
    "title": {
      "type": "text",
      "stored": true
    },
    "description": {
      "type": "text",
      "stored": true
    },
    "id": {
      "type": "u64",
      "indexed": true,
      "stored": true,
      "fast": "single"
    }
  },
  "boost_fields": {
    "title": 2,
    "description": 0.8
  }
}
# curl -X POST -d@a.json -H "Content-Type: application/json" http://127.0.0.1:4040/indexes
{"data":"index created","status":200}
# cat b.json
{
    "title": ["Hello, World"],
    "description": ["Welcome to the next generation system."]
}
# curl -X POST -H "Content-Type: application/json" -d@b.json http://localhost:4040/indexes/my-index/documents?wait=true
{"data":"added documents","status":200}
# curl -X POST 'http://localhost:4040/indexes/my-index/commit'
{"data":"changes committed","status":200}
# curl 'http://localhost:4040/indexes/my-index/search?query=*'
{"data":{"count":0,"hits":[],"time_taken":0.001682035974226892},"status":200}
# curl 'http://localhost:4040/indexes/my-index/search?query=Hello'
{"data":{"count":0,"hits":[],"time_taken":0.00014333099534269422},"status":200}

I can't figure out what I'm doing wrong here.

@ChillFish8
Copy link
Collaborator

ChillFish8 commented Aug 27, 2021

This is because by default the fuzzy mode is used (generally what most developers will use it for) which will take that * as a literal instead of feeding it to the parser. adding mode=normal to the query string on the URL should fix this.

@ChillFish8 ChillFish8 added the question Further information is requested label Aug 27, 2021
@ChillFish8
Copy link
Collaborator

As for the last cURL request, I'm not sure 🤔 If you create this index without fast fuzzy being enabled ("use_fast_fuzzy": false) does this behave the same?

@ChillFish8
Copy link
Collaborator

Okay, I think I know what's going on here. This is a side effect of adding "use_fast_fuzzy": true when the correction system is not enabled on the server runtime (via --enable-fast-fuzzy) currently this will make the system default to standard fuzzy matching regardless of the index definition. This is typically fine except the schema takes what you give use_fast_fuzzy as gospel and was preparing documents as if fast-fuzzy is enabled on the server.

If you remove use_fast_fuzzy and then test this should work as expected. Shall do a patch now.

@miyachan
Copy link
Author

miyachan commented Aug 27, 2021

So in this bug, you are right that was the cause. I copied this example from the book and assumed I was hitting the same issue. What I am actually seeing is that when I index a document with a date field, I am no longer able to index any more documents.

# curl -X DELETE  'http://localhost:4040/indexes/my-index'
{"data":"index deleted","status":200}# 
# cat a.json
{
  "name": "my-index",
  "writer_buffer": 6000000,
  "writer_threads": 1,
  "reader_threads": 1,
  "max_concurrency": 10,
  "search_fields": [
    "title"
  ],
  "storage_type": "memory",
  "use_fast_fuzzy": false,
  "strip_stop_words": false,
   "set_conjunction_by_default": false,
  "fields": {
    "title": {
      "type": "text",
      "stored": true
    },
    "description": {
      "type": "text",
      "stored": true
    },
    "id": {
      "type": "u64",
      "indexed": true,
      "stored": true,
      "fast": "single"
    },
 "ts": {
            "type": "date",
            "stored": false,
            "indexed": true,
            "fast": "single"
        }
  },
  "boost_fields": {}
}
# curl -X POST -d@a.json -H "Content-Type: application/json" http://127.0.0.1:4040/indexes
{"data":"index created","status":200}
# cat c.json
{
    "title": ["Hello, World2"],
"id":[4]
}
# curl -X POST -d@c.json -H "Content-Type: application/json" http://localhost:4040/indexes/my-index/documents?wait=true
{"data":"added documents","status":200}
# curl -X POST 'http://localhost:4040/indexes/my-index/commit'
{"data":"changes committed","status":200}
# curl 'http://localhost:4040/indexes/my-index/search?query=*&mode=normal'
{"data":{"count":1,"hits":[{"doc":{"id":[4],"title":["Hello, World2"]},"document_id":"8295453496340348446","ratio":1.0}],"time_taken":0.0001392010017298162},"status":200}
# cat b.json
{
    "title": ["Hello, World2"],
"id":[4],
"ts":[1630097583]
}
# curl -X POST -d@b.json -H "Content-Type: application/json" http://localhost:4040/indexes/my-index/documents?wait=true
{"data":"added documents","status":200}
# curl -X POST 'http://localhost:4040/indexes/my-index/commit'
{"data":"changes committed","status":200}
# curl 'http://localhost:4040/indexes/my-index/search?query=*&mode=normal'
{"data":{"count":1,"hits":[{"doc":{"id":[4],"title":["Hello, World2"]},"document_id":"8295453496340348446","ratio":1.0}],"time_taken":0.0001936009939527139},"status":200}

Adding a document with a date field doesn't produce an error, but seems to corrupt the index. In my original setup, I always had a date field, and I wasn't seeing any documents get indexed, which is why I assumed the two errors were the same. Once this happens even documents without the ts field fail to be indexed.

@ChillFish8
Copy link
Collaborator

Ill move this to a new issue as I don't believe they're related.

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

Successfully merging a pull request may close this issue.

2 participants