Giter VIP home page Giter VIP logo

Comments (2)

Mpdreamz avatar Mpdreamz commented on May 16, 2024

Hi clarkb,

I've committed some additional unit tests that do a better job describing how to branch queries then i could probably type up:

https://github.com/Mpdreamz/NEST/blob/29e5973332f89fc48ccfced3944cd935544230df/src/Nest.Tests.Unit/Query/Bool/StaticBoolQueryTests.cs

I did a longish write up here on how to dynamically generate searchdescriptors here:
#52

I wrote that before NEST had proper &&, || and ! support and before it had a static Query, Query<T> , Filter and Filter<T> of which to spawn queries at will.

Hopefully i get around to writing some proper documentation on all the different query generation paths you can take (NEST has several) somewhere next week.

I hope this for now answers your question though.let me know if it doesn't!

from elasticsearch-net.

digitalhurricane avatar digitalhurricane commented on May 16, 2024

It still wasn't clear to me how to do this based on the additional tests, but I came up with the following:

var filter = Filter<Part>.Term(x => x.DivisionID, divisionId);
if (classId != "")
{
    filter &= Filter<Part>.Query(f => f.QueryString(q => q.Query(classId).OnField(field => field.ClassID)));
}
if (subclassId != "")
{
    filter &= Filter<Part>.Query(f => f.QueryString(q => q.Query(subclassId).OnField(field => field.SubClassID)));
}

Would that be the right way to do it? I now have to do something similar but this time I need to create a multiple-value "or" filter. Using the above example, I'd have a string array of division IDs and need to match on any of them. The array could be any length, so I'm not sure if I have to loop through it and add an or filter for each value or if I can pass in the string array to something as the set of values to match.

from elasticsearch-net.

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.