Comments (5)
Hi @fulmicoton,
It makes sense what you say about treating =
the same as
(spaces) if I wrap it in quotes.
I think I'm able to reproduce what I didn't understand, though, sorry in advance if it ends up being some elementary encoding issue!
-
Copy
tantivy
binary to a directory, andmkdir index
-
Create new index
$ ./tantivy new -i index/
Creating new index
Let's define it's schema!
New field name ? text
Text or unsigned 32-bit integer (T/I) ? t
Should the field be stored (Y/N) ? n
Should the field be indexed (Y/N) ? y
Should the field be tokenized (Y/N) ? y
Should the term frequencies (per doc) be in the index (Y/N) ? y
Should the term positions (per doc) be in the index (Y/N) ? y
Add another field (Y/N) ? y
New field name ? name
Text or unsigned 32-bit integer (T/I) ? t
Should the field be stored (Y/N) ? y
Should the field be indexed (Y/N) ? n
Add another field (Y/N) ? n
[
{
"name": "text",
"type": "text",
"options": {
"indexing": "position",
"stored": false
}
},
{
"name": "name",
"type": "text",
"options": {
"indexing": "unindexed",
"stored": true
}
}
]
- Add a
key="value"
text to index
$ echo '{"name":"raul","text":"i am phrase=\"value\""}' | ./tantivy index -i index/
Commit succeed, docstamp at 1
Waiting for merging threads
Terminated successfully!
- Add another document with different words between to not match the phrase
$ echo '{"name":"paul","text":"i am not a phrase with value"}' | ./tantivy index -i index/
Commit succeed, docstamp at 2
Waiting for merging threads
Terminated successfully!
- Serve the index
$ ./tantivy serve -i index/
listening on http://localhost:3000
Attempts to isolate the first document which contains phrase="value"
Attempt 1
$ ./tantivy search -i index/ -q '"phrase=\"value\""'
{"name":["raul"]}
{"name":["paul"]}
Attempt 2
$ ./tantivy search -i index/ -q '"phrase=\\"value\\""'
{"name":["raul"]}
{"name":["paul"]}
Attempt 3
$ ./tantivy search -i index/ -q '"phrase=\\\"value\\\""'
{"name":["raul"]}
{"name":["paul"]}
(pause to laugh at https://xkcd.com/1638/)
Attempt 4
$ curl "http://localhost:3000/api/?q=%22phrase%3D%5C%22value%5C%22%22"
{
"q": "\"phrase=\\\"value\\\"\"",
"num_hits": 2,
"hits": [
{
"doc": {
"name": [
"raul"
]
}
},
{
"doc": {
"name": [
"paul"
]
}
}
],
Attempt 5 - If i replace =
,"
with spaces, it returns the one document
$ ./tantivy search -i index/ -q '"phrase value"'
{"name":["raul"]}
$ curl "http://localhost:3000/api/?q=%22phrase%20value%22"
{
"q": "\"phrase value\"",
"num_hits": 1,
"hits": [
{
"doc": {
"name": [
"raul"
]
}
}
],
from tantivy-cli.
=
signs are treated as a whitespace both by the analyzer and the
QueryParser
.
Also by default the QueryParser
treats sequence of tokens as
disjunctions, so your query is logically equivalent to name OR anonymous.
To get the result you expect you need to add quotation marks around your
query to declare it as a PhraseQuery
.
Note it would then still match a doc that contains a space in place of the
equal. This problem cannot be solved without using a custom analyzer.
Finally, if you are performance critical there is also plenty of room to
make your use case run much faster.
from tantivy-cli.
Thanks @fulmicoton. That makes sense. I've found that some queries with special characters work as expected (with phrase matching) in CLI, but can not be properly escaped using the serve
API.
For now I've just replaced them with a
(space) and seems to do the trick.
Thanks!
from tantivy-cli.
That's surprising. In your response payload repeats the query. In your example the = sign was decoded correctly. If you add double quotation marks in your query you don't get the result you expect?
from tantivy-cli.
Thanks for the great bug report. I'll have a look at that soonish!
from tantivy-cli.
Related Issues (20)
- Update to use tantivy 0.13 HOT 1
- Search command println panics with broken pipes HOT 3
- Compilation issue when running `cargo install tantivy-cli` HOT 2
- Rephrase Question: Should the field be fast HOT 1
- Prefix search HOT 1
- I do create f64 field, it creates text field HOT 2
- Successfully build on target "aarch64-unknown-linux-musl" but got "Illegal instruction (core dumped)" error when run HOT 1
- benchmark command shows 4 head columns but only 3 data columns HOT 1
- Add inspect command to print space usage
- How to define schema for source code? HOT 2
- CLI panics if schema contains an json_document field type HOT 4
- ask for fast field on text
- Thread Merge Error HOT 3
- What should be the schema for a non json log text file HOT 1
- CLI panics when `agg` option is omitted HOT 2
- panic in `merge_thread_0`, v0.19.0 from crates.io HOT 10
- Fails to compile with cargo install HOT 1
- Panic when serving with tantivy-cli v0.22.0 HOT 1
- Broken with nightly
- Question: is it possible to remove or update a document from the index?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tantivy-cli.