GithubHelp home page GithubHelp logo

Comments (9)

YosefMac avatar YosefMac commented on May 18, 2024

This should work:

{ "_query": {"fieldname": { "_and": "hello world"} } }

from xapiand.

ngrilly avatar ngrilly commented on May 18, 2024

from xapiand.

YosefMac avatar YosefMac commented on May 18, 2024

Docs I guess this is what you looking for:

{
  "_query": {
    "_or": [
      {
        "fieldname": "hello"
      },
      {
        "fieldname": "world"
      }
    ]
  }
}

from xapiand.

ngrilly avatar ngrilly commented on May 18, 2024

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.

YosefMac avatar YosefMac commented on May 18, 2024

I think I'm still without understand. The search "hello OR world" is done by the example above, but you have to use _orexplicitly.

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.

ngrilly avatar ngrilly commented on May 18, 2024

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.

YosefMac avatar YosefMac commented on May 18, 2024

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.

ngrilly avatar ngrilly commented on May 18, 2024

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.

YosefMac avatar YosefMac commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.