Comments (9)
This should work:
{ "_query": {"fieldname": { "_and": "hello world"} } }
from xapiand.
from xapiand.
Docs I guess this is what you looking for:
{
"_query": {
"_or": [
{
"fieldname": "hello"
},
{
"fieldname": "world"
}
]
}
}
from xapiand.
I realize my answer wasn't clear.
The query string is provided by the end user. I want it to be parsed by Xapiand, using the equivalent of Xapian::QueryParser, with the default boolean operator being AND instead of OR.
This means the query string "hello world" should be equivalent to "hello AND world" (implicit AND between words). But the user should also be able to search "hello OR world".
from xapiand.
I think I'm still without understand. The search "hello OR world" is done by the example above, but you have to use _or
explicitly.
The query user must be in the way of QueryDSL .
We don't use Xapian::QueryParser except when the type is text
and only for add stemming and others stuff.
The must similar thing that you can do is send query params in the SEARCH method rather that the json body with QueryDSL. Something like this:
SEARCH /mydb/?q=fieldname:hello%20OR%20fieldname:world
But we discourage use of this way because at the end is parsed to QueryDSL form, and just add overhead and in the future versions perhaps is not supported.
from xapiand.
I'm working on an app in which the end user can enter a search query in a standard text field widget.
A query can be as simple as hello world
or as complex as apple AND a NEAR word OR "a phrase" NOT (too difficult) +eh
. This is why I'd like to reuse the syntax of Xapian::QueryParser
. More info here.
And I cannot ask the end user to express the query as a JSON object representing an Abstract Syntax Tree ;-)
from xapiand.
For this case you can use the SEARCH method and send the user query hello OR world
in the request query param and use the index mode "_index": "terms"
this allow search without the field and the query syntax is going to be more like you looking for:
SEARCH /mydb/?query=hello OR world
The logical operators that are supported in this mode are: AND, MAYBE, OR, NOT, XOR. This also support use of parenthesis for operator precedence, the phrases are supported as well but not +/-
operators
from xapiand.
I've upgraded to v0.29.0. SEARCH /mydb/?query=hello OR world
and SEARCH /mydb/?query=hello AND world
work now. But SEARCH /mydb/?query=hello world
(without any boolean operator between words) fails with this message: Bad Request: Bad boolean expression
.
from xapiand.
Yes, there wasn't implicit default operator in this query mode. Should work in 460c8d9. Thanks again for the report!!
from xapiand.
Related Issues (20)
- N-Gram index/search example HOT 3
- Listing of indices HOT 3
- Build fails with -DCLUSTERING="OFF" HOT 1
- Segmentation fault on Alpine v3.9 HOT 1
- Limit query execution time HOT 1
- How to search in all fields? HOT 4
- Result Highlighting HOT 2
- Option to store (or not store) field HOT 1
- Xapaind Glossary Terms
- Data Encryption HOT 3
- How to config a cluster without multicast? HOT 1
- Write performance problem, can not reach 1000qps HOT 5
- Google Cloud Run
- compile with cmake : linking (error) HOT 3
- Is there any document explaining the config of xapiand? HOT 2
- License question
- upgrade to Xapian 1.4.16
- DELETE all documents
- Is this project dead? HOT 2
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 xapiand.