Search code examples
c#ignite

How to use Ignite Cache TextQuery in .Net Application


I am using Apache Ignite v2.7.6.And I have a .Net core ClientServer Ignite App. I am trying to read/search text from the Person Model field Payload marked with QueryTextField.

TextQuery Ignite Docs.

Person Model:

public class Person: IConstructionCacheStore
    {
        [QueryTextField]
        public string Payload { get; set; }
    }

Code:

using (IIgniteClient client = Ignition.StartClient(this._igniteClientConfiguration))
            {
                //get cache config 
                var cache = client.GetCache<string, IConstructionCacheStore>(cacheName);
                try
                {
                    // Query for all people with "Master Degree" in their resumes.
                    var cursor = cache.Query(new TextQuery("Person", "Master Degree"));//Error

                    // Iterate over results. Using 'foreach' loop will close the cursor automatically.
                    foreach (var cacheEntry in cursor)
                        Console.WriteLine(cacheEntry.Value);
                }
                catch (Exception ex)
                {
                    throw;
                }

            }

But I am getting a compile-time error at cache.Query(new TextQuery("Person", "Master Degree")); like

Error CS1503 Argument 1: cannot convert from 'Apache.Ignite.Core.Cache.Query.TextQuery' to 'Apache.Ignite.Core.Cache.Query.ScanQuery<string, ConstructionModels.IConstructionCacheStore>'

is TextQuery support in .Net? How to solve above error?

Thanks.


Solution

  • TextQuery is not supported in Ignite thin clients:

    • Use thick client instead (.NET thick client supports TextQuery)
    • Use Services or Compute as a workaround (wrap TextQuery call in a Service or Compute Task, use thin client to call the service or the task)