QtSql Fuzzy search - qt

I am working with QSQLITE database in qt and attempt to implement fuzzy search in our program our sql query is something like this:
select name from things where name like '%arg%'
it's not the same the query is longer has joins and etc.
I tried using SOUND and SOUNDEX() but I think none of them is supported in QSQLITE is there any way I can implement fuzzy search here?

For soundex support, you would have to recompile the SQLite library embedded in Qt.
There is no other built-in 'fuzzy' function.
Either implement your own custom function, or store a normalized version of your string in the database so that you can compare it directly.

Related

How to use geoshape in gremlinpython

In JanusGraph,there is some function like
g.E().has('place', geoWithin(Geoshape.circle(37.97, 23.72, 50)))
to search place data. Now I want to use gremlinpython to do that,but I can't find the suitable API from the document.
Gremlin does not yet support Geo data types and predicates. The bits of syntax that you are referencing are specific to JanusGraph and are part of its libraries. At this point, I don't believe that JanusGraph has a Python specific library to give you direct access to those things. If you need to use Geo searches then, for now, you will need to submit a Gremlin script to JanusGraph Server with that syntax.
Something like this:
g.V().has('polygon',geoIntersect(Geoshape.point(55.70,37.55)))

Decimal/Date Sorting With Entity Framework Core and SQLite

Using Entity Framework Core (Code First) and SQLite, Guid is stored as binary but Decimal and Date fields are stored as text with Microsoft's provider.
I can understand they might not want the imprecision of DOUBLE for currency amounts and thus use text.
What happens if I need to sort? Is Entity Framework Core smart enough to make sorting work as expected (but slower because it needs to parse everything!), or will it sort alphabetically instead of sorting by number? I don't want it to return 100 before 2.
I'll have to do things like "give me the latest order" so what's the best approach for that? I want to make sure it's going to work.
Am I better to switch to System.Data.SQLite provider to store dates in UNIX format (this is not supported by the Microsoft's provider)? and then would I have to do the parsing back and forth myself or it could take care of it automatically?
I am still learning system.data.sqlite myself, but I am aware that you can create and assign a custom collation to your column. The collation can either be assigned to the table column, or only to a particular view or query using standard sqlite SQL syntax and the COLLATE keyword.
This is not a complete example/tutorial, but for starters visit the Microsoft.data.sqlite docs. Also see this stack overflow answer. These are just hints, but provide a consistent method to do this. Remember that sqlite is an in-process DB engine, so it should still be rather efficient and still allow working with the database in a normal fashion without having to constantly inject custom logic between queries. Once you have the custom collation defined and properly registered, it should be rather seamless with perhaps the only extra requirement to append e.g. COLLATE customDecimal to the ORDER BY clauses.
The custom collation function would convert the string value to an appropriate numeric type and return the comparison. It's very similar to the native .Net IComparer and IComparison interfaces/implementations.

Accessing CoreData tables from fmdb

I'm using CoreData in my application for DML statements and everything is fine with it.
However I don't want use NSFetchedResultsController for simple queries like getting count of rows, etc.
I've decided to use fmdb, but don't know actual table names to write sql. Entity and table names don't match.
I've even looked inside .sqllite file with TextEdit but no hope :)
FMResultSet *rs = [db getSchema] doesn't return any rows
Maybe there's a better solution to my problem?
Thanks in advance
Core Data prefixes all its SQL names with Z_. Use the SQL command line tools to check out the your persistent store file to see what names it uses.
However, this is a very complicated and fragile solution. The Core Data schema is undocumented and changes without warning because Core Data does not support direct SQL access. You are likely to make error access the store file directly and your solution may break at random when the API is next updated.
The Core Data API provides the functionality you are seeking. IJust use a fetch request that fetches on a specific value using an NSExpressionDescription to perform a function. This allows you to get information like counts, minimums, maximums etc. You can create and use such fetches independent of a NSFetchedResultsController.
The Core Data API is very feature rich. If you find yourself looking outside the API for a data solution, chances are you've missed something in the API.

Open source LINQ search engine for website

I want to add a search engine to my website. I want it to handler boolean searches and give me a list of results in order or best match. I need it to be able to work with LINQ, because I want to add additional where clauses to the final query that gets run. I am looking for the best open source .NET search engine that works with LINQ. I like lucene.net but the problem is the LINQ interface (LINQ to Lucene) hasn't been updated since 2008. Are there any good options out there?
You could try and use the free Search Server Express from Microsoft. It's available in beta for the 2010 version but will be released soon. The (SharePoint) Search API is very similar similar to SQL, so you could append additional where clauses.
It's not linq or open source, but it's free and might work in your case. I've looked a bit at the lucene linq api myself, and came to the same conclusion you have. It's not updated, while Lucene is still being worked on.
The other option is to create your own Lucene Linq provider, but it will require some work.
Documentation for the FullTextSqlQuery class. (old version docs with sample here)
Here's a code snippet to show what it looks like:
FullTextSqlQuery fullTextSqlQuery = new FullTextSqlQuery(site)
fullTextSqlQuery.QueryText = String.Format("SELECT Title, SiteName, Path FROM Scope() WHERE \"scope\"='All Sites' AND CONTAINS('\"{0}\"')", searchPhrase),
and you could append more to the WHERE part of the query.
I decided to use full-text indexing feature of sql server. It's not as full featured as lucene.net but for my requirements it gets the job done pretty well.

Detect the FTS3 extension in SQLite3

What is the SQLite query to detect if the FTS3 extension module is installed? Or is it possible to get a list of installed extensions with an SQLite3 query? It has to work with pysqlite2.
I know that I can get the list of tables using SELECT * FROM sqlite_master, I'd like to get something similar for the list of extensions. I also know that CREATE VIRTUAL TABLE v USING FTS3 (t TEXT) succeeds iff FTS3 is installed, but I'd like to get a query without side effects (not even creating a temporary table).
As a workaround I have opened the ":memory:" database, and issued the CREATE VIRTUAL TABLE command above.
There is no way to do it in SQLite at the moment; it forgets what it has loaded and cannot report it even if it wanted to (I checked the source to the code that does the loading, and the critical information that describes what is loaded is just not stored). It is known (see Wish List at the bottom of that page) that it would be good to retain this information, but it does not appear to be retained as yet.
As a consequence, the only thing you can do is your current workaround – trying it and seeing if it works. Sorry I can't offer anything else.

Resources