mongodb-labs / mongo-csharp-search

C# driver extension providing support for Atlas Search
Apache License 2.0
17 stars 1 forks source link

How to use #2

Closed ghendo closed 2 years ago

ghendo commented 2 years ago

I want to do a wildcard search and tried Collection.Aggregate() .Search( SearchBuilders.Search .Wildcard("John","*",true)) .ToList();

which did not return anything Any chance for a bit of help?

dgolub commented 2 years ago

If you're trying to searching for "John" in any field, then what you need is a wildcard search path. This is not yet supported in Beta 1, but the change adding support for it was recently committed and will be included in Beta 2. Once it's released, you'll want to do something along the lines of the following:

Collection.Aggregate()
    .Search(
        SearchBuilders.Search
            .Phrase(
                "John",
                SearchBuilders.Path
                    .Wildcard("*")))
    .ToList()
dgolub commented 2 years ago

Beta 2 has now been released: https://www.nuget.org/packages/MongoDB.Labs.Search/1.0.0-beta2

You should be able to gain access to the feature that you've requested by upgrading to the new version.

ghendo commented 2 years ago

I got an error as conflict with version of mongodb.driver

dgolub commented 2 years ago

What versions are you using? There were some changes to interfaces used by the Atlas Search extension in version 2.14 of the driver, so you'll need to upgrade if you're using an earlier version.

ghendo commented 2 years ago

Its ok now. I uninstalled both this and the driver and reinstalled and now works