Ignite cache TextQuery on JsonString data Field

classic Classic list List threaded Threaded
8 messages Options
siva siva
Reply | Threaded
Open this post in threaded view
|

Ignite cache TextQuery on JsonString data Field

This post was updated on .
Hi All,
I am using ApacheIgnite2.7.6 .Net Core.And I have .Net ClientServer App.And for Cache creation using QueryEntity CacheConfiguration.And for
Data loading in Ignite cache using DataStreamer AddData(key,model) method.

Model class:


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

where Payload field contains jsonstring as data.
for example Payload data
{
  "comments": "Enter a description of the daily activities",
  "authorname": "chhoturam jat",
  "project": "Auto Mobile",
  "count": "4",
  "userid": "0a2802ca-4970-477b-b4be-0cb74a67dcbc"
}



Code:
 try
            {
                var cache = _IGNITE_CLIENT.GetOrCreateCache<string, IConstructionCacheStore>(cacheName);
                var textquery = new TextQuery(typeof(CommonConstruction), "Mobile");
                var cursor = cache.Query(textquery);
                foreach (var cacheEntry in cursor)
                    Console.WriteLine(cacheEntry.Value);
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex);
            }

cursor cacheEntry contains no result.

How to get data in result and what i need to change?

Thanks.
ibelyakov ibelyakov
Reply | Threaded
Open this post in threaded view
|

Re: Ignite cache TextQuery on JsonString data Field

Hi,

Seems like you should use "Person" as a type for the TextQuery instead of
"CommonConstruction", here:
/var textquery = new TextQuery(typeof(CommonConstruction), "Mobile");/

Igor




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
siva siva
Reply | Threaded
Open this post in threaded view
|

Re: Ignite cache TextQuery on JsonString data Field

This post was updated on .
Hi,
I have modified like this but still cursor cacheEntry contains no result.

var textquery = new TextQuery("Person", "Mobile");




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ibelyakov ibelyakov
Reply | Threaded
Open this post in threaded view
|

Re: Ignite cache TextQuery on JsonString data Field

Can you provide your CacheConfiguration?

Igor



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
siva siva
Reply | Threaded
Open this post in threaded view
|

Re: Ignite cache TextQuery on JsonString data Field

This post was updated on .
Hi,
please find the Cache configuration details give below.



struct QueryEntityIndexFields
{
	public string[] PrimaryKeys;
	public Type ModelType;        
}
	
QueryEntityIndexFields[] queryEntityIndexFieldsList = new[] {            
    new QueryEntityIndexFields(){PrimaryKeys=new []{ "UUID" }, ModelType=  typeof(Person) }            
 };

 
List<QueryEntity> queryList = new List<QueryEntity>();
foreach (var modelObject in queryEntityIndexFieldsList)
{
	var query = new QueryEntity(typeof(string), modelObject.ModelType)
	{
		Indexes = new List<QueryIndex>(modelObject.PrimaryKeys.Count() + 1)
			{
				new QueryIndex(true,0,modelObject.PrimaryKeys)
			}
	};
	queryList.Add(query);
}
            
cacheName = cacheName.ToUpper();
var templateName = cacheName.Remove(cacheName.Length - 1, 1) + "*";

var cacheCfg = new CacheConfiguration(templateName)
{
	Name = cacheName,
	CacheStoreFactory = new ConstructionTenantCacheStoreFactory(_logger, connectionString),
	KeepBinaryInStore = false,  // Cache store works with deserialized data.
	ReadThrough = true,
	WriteThrough = true,
	WriteBehindEnabled = true,
	QueryEntities = queryList,
	WriteBehindFlushThreadCount = 2,
	CacheMode = CacheMode.Partitioned,
	Backups = 0,
	DataRegionName = "IgniteDataRegion",
	EvictionPolicy = new LruEvictionPolicy
	{
		MaxSize = 100000
	}
};
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Ignite cache TextQuery on JsonString data Field

Hello!

Unfortunately, nothing is visible in your e-mails.
Please provide images/files as links.

Regards,
--
Ilya Kasnacheev


пн, 30 нояб. 2020 г. в 20:00, siva <[hidden email]>:
Hi,
please find the Cache configuration details give below.







--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ptupitsyn ptupitsyn
Reply | Threaded
Open this post in threaded view
|

Re: Ignite cache TextQuery on JsonString data Field

I can't see any details in the email too.
However, code is visible on Nabble [1]
Weird.


On Mon, Dec 14, 2020 at 5:03 PM Ilya Kasnacheev <[hidden email]> wrote:
Hello!

Unfortunately, nothing is visible in your e-mails.
Please provide images/files as links.

Regards,
--
Ilya Kasnacheev


пн, 30 нояб. 2020 г. в 20:00, siva <[hidden email]>:
Hi,
please find the Cache configuration details give below.







--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Ignite cache TextQuery on JsonString data Field

In reply to this post by siva
Hello!

I'm not sure that our text indexing will tokenize your JSON correctly. Can you try just putting some simple word in that field and trying text search?

Regards,
--
Ilya Kasnacheev


пн, 30 нояб. 2020 г. в 16:39, siva <[hidden email]>:
Hi All,
I am using ApacheIgnite2.7.6 .Net Core.And I have .Net ClientServer App.And
for Cache creation using QueryEntity CacheConfiguration.And for
Data loading in Ignite cache using DataStreamer AddData(key,model) method.
*
Model class:*



where Payload field contains jsonstring as data.
*for example Payload data*


*
<http://apache-ignite-users.70518.x6.nabble.com/file/t1379/TextQueryTableResult.png>
*

*Code:*


cursor cacheEntry contains no result.

How to get data in result and what i need to change?

Thanks.




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/