Using Apache Ignite .NET 2.3.0
Trying to search using Linq extension (Apache.Ignite.Linq).
Here is a IgniteConfig:
{
ClientMode = false,
JvmInitialMemoryMb = 512,
JvmMaxMemoryMb = 512,
MetricsLogFrequency = TimeSpan.Zero, // disable metrics output
DataStorageConfiguration = new Apache.Ignite.Core.Configuration.DataStorageConfiguration()
{
DefaultDataRegionConfiguration = new DataRegionConfiguration()
{
Name = "DefaultRegion",
PersistenceEnabled = true
},
StoragePath = _config.Value.Ignite.PersistentStoragePath
},
CacheConfiguration = new[]
{
new CacheConfiguration
{
Name = "securitiesItemsCache",
ReadThrough = false,
WriteThrough = false,
CacheMode = CacheMode.Replicated,
DataRegionName = "DefaultRegion",
QueryEntities = new []
{
new QueryEntity(typeof(string), typeof(SecuritiesItem))
}
}
}
Getting cache:
_securitiesCache = _ignite.GetOrCreateCache<string, SecuritiesItem>("securitiesItemsCache");
Searching like this:
_securitiesCache
.AsCacheQueryable()
.Where(s => s.Value.SearchString.Contains(query))
.ToArray()
.Select(x => x.Value);
In this case recieve exception:
Apache.Ignite.Core.Common.IgniteException HResult=0x80131500
Message=Failed to parse query: select _T0._KEY, _T0._VAL from "securitiesItemsCache".SECURITIESITEM as _T0 where (_T0.SearchString like '%' || ? || '%') Source=Apache.Ignite.Core StackTrace: at Apache.Ignite.Core.Impl.Unmanaged.UnmanagedCallbacks.Error(Void* target, Int32 errType, SByte* errClsChars, Int32 errClsCharsLen, SByte* errMsgChars, Int32 errMsgCharsLen, SByte* stackTraceChars, Int32 stackTraceCharsLen, Void* errData, Int32 errDataLen) at Apache.Ignite.Core.Impl.Unmanaged.IgniteJniNativeMethods.TargetInStreamOutObject(Void* ctx, Void* target, Int32 opType, Int64 memPtr) at Apache.Ignite.Core.Impl.PlatformJniTarget.InStreamOutObject(Int32 type, Action1 writeAction) at Apache.Ignite.Core.Impl.Cache.CacheImpl
2.QueryFields[T](SqlFieldsQuery qry, Func3 readerFunc) at Remotion.Linq.Clauses.StreamedData.StreamedSequenceInfo.ExecuteQueryModel(QueryModel queryModel, IQueryExecutor executor) at Apache.Ignite.Linq.Impl.CacheFieldsQueryProvider.Execute[TResult](Expression expression) at Remotion.Linq.QueryableBase
1.GetEnumerator() at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable
1 items) at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable
1 source) at Core.IgniteServer.SearchSecurities(String query) in C:\development\ISSDPService\Core\IgniteServer.cs:line 138 at WebService.Providers.IgniteProvider.Search(String query, LanguagePrefix lang) in C:\development\ISSDPService\WebService\Providers\IgniteProvider.cs:line 78 at WebService.Controllers.SecuritiesController.Search(String query) in C:\development\ISSDPService\WebService\Controllers\SecuritiesController.cs:line 47 at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__12.MoveNext()Inner Exception 1: JavaException: class org.apache.ignite.IgniteCheckedException: Failed to parse query: select _T0._KEY, _T0._VAL from "securitiesItemsCache".SECURITIESITEM as _T0 where (_T0.SearchString like '%' || ? || '%') at org.apache.ignite.internal.processors.platform.utils.PlatformUtils.unwrapQueryException(PlatformUtils.java:519) at org.apache.ignite.internal.processors.platform.cache.PlatformCache.runFieldsQuery(PlatformCache.java:1240) at org.apache.ignite.internal.processors.platform.cache.PlatformCache.processInStreamOutObject(PlatformCache.java:877) at org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl.inStreamOutObject(PlatformTargetProxyImpl.java:79) Caused by: javax.cache.CacheException: class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to parse query: select _T0._KEY, _T0._VAL from "securitiesItemsCache".SECURITIESITEM as _T0 where (_T0.SearchString like '%' || ? || '%') at org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.query(IgniteCacheProxyImpl.java:597) at org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.query(GatewayProtectedCacheProxy.java:368) at org.apache.ignite.internal.processors.platform.cache.PlatformCache.runFieldsQuery(PlatformCache.java:1234) ... 2 more Caused by: class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to parse query: select _T0._KEY, _T0._VAL from "securitiesItemsCache".SECURITIESITEM as _T0 where (_T0.SearchString like '%' || ? || '%') at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryDistributedSqlFields(IgniteH2Indexing.java:1385) at org.apache.ignite.internal.processors.query.GridQueryProcessor$5.applyx(GridQueryProcessor.java:1909) at org.apache.ignite.internal.processors.query.GridQueryProcessor$5.applyx(GridQueryProcessor.java:1907) at org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36) at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2445) at org.apache.ignite.internal.processors.query.GridQueryProcessor.querySqlFields(GridQueryProcessor.java:1914) at org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.query(IgniteCacheProxyImpl.java:585) ... 4 more Caused by: org.h2.jdbc.JdbcSQLException: Столбец "_T0.SEARCHSTRING" не найден Column "_T0.SEARCHSTRING" not found; SQL statement: select _T0._KEY, _T0._VAL from "securitiesItemsCache".SECURITIESITEM as _T0 where (_T0.SearchString like '%' || ? || '%') [42122-195] at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) at org.h2.message.DbException.get(DbException.java:179) at org.h2.message.DbException.get(DbException.java:155) at org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:147) at org.h2.expression.CompareLike.optimize(CompareLike.java:93) at org.h2.command.dml.Select.prepare(Select.java:842) at org.h2.command.Parser.prepareCommand(Parser.java:262) at org.h2.engine.Session.prepareLocal(Session.java:573) at org.h2.engine.Session.prepareCommand(Session.java:514) at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1204) at org.h2.jdbc.JdbcPreparedStatement.(JdbcPreparedStatement.java:73) at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:288) at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatement(IgniteH2Indexing.java:402) at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryDistributedSqlFields(IgniteH2Indexing.java:1365) ... 10 more
it says:
Column "_T0.SEARCHSTRING" not found; SQL statement:
But is't new QueryEntity(typeof(string), typeof(SecuritiesItem))
enought fo this?
Resolved
Added description for field programmatically:
Fields = new []
{
new QueryField { Name = "SearchString", FieldType = typeof(string)}
}
Another problem.
It searching great if query consists only of English letters. But if i enter Russian characters, then nothing finds. Should I convert the text into a specific encoding?
Column "_T0.SEARCHSTRING" not found
You should mark SearchString
property with [QuerySqlField]
.
SQL is opt-in, you should explicitly configure which fields should be available in queries. See https://apacheignite-sql.readme.io/docs/net-schema-and-indexes.