I have a SQLite3 database that is using FTS3. It works well in SQLite3 commandline tool but when using C library (using wxSQLite3, but that should not make difference I guess), it does not work with queries containing "-" character something like
SELECT * From Table WHERE columnx MATCH 'text1 -text2'. However, this works fine on commandline version.
I have no Idea why it does not work. All other FTS Match condition I have tried works fine.
Note: I have added wxWidgets to tags instead of wxSQLite3 as I cannot create new tags
Apparently, your databases are configured differently regarding standard/enhanced query syntax; try WHERE columnx MATCH 'text1 NOT text2'.
To enable enhanced query syntax, compile with the SQLITE_ENABLE_FTS3_PARENTHESIS macro.
Related
So I'm running into a very weird issue. I'm using Django's SearchQuery app in Django, using Django 3.2.1 and the most up to date PostgreSQL. The issue emerges when I use a search query with websearch and config set to english.
Here is the initial code for the instantiation of the search_query with config='english'
search_query = SearchQuery(query_string, search_type='websearch', config='english')
And this is the code for when I search for it:
agenda_items = AgendaItem.objects.annotate(search=SearchVector('name', 'description', 'note'),search_rank=SearchRank('search', search_query)).filter(search=search_query).order_by('-search_rank').distinct()
This works for most words, but I have found some weird outliers. For instance, it works when I search "flamingo" and it correctly matches it.
However, when I search for the word "cupcake" it displays nothing, despite the word actually being present in many records in the correct spots.
However, if I remove config='english' from the SearchQuery it works. But without that, I lose the English language support to stem words.
Does anyone have any ideas?
I am writing a ColdFusion program that uses cfquery to get data from an AS/400 iSeries table and then output that data to a web page. Some times the Data is in Chinese, but it does not output the Chinese characters correctly.
I built the query below for testing,
<cfprocessingdirective pageEncoding="UTF-8" />
<cfquery name="Test" Datasource = "AS400">
select dsc1 from sales where ref = '123456'
</cfquery>
<cfoutput>#test.dsc1#</cfoutput>
The result should be "M5方头螺栓" but I only get "M5". I did another test running just:
<cfset x = "M5方头螺栓"/>
<cfoutput>#x#</cfoutput>
and it displays the Chinese no problem.
Since ColdFusion can display the characters when they are written out in the code, but not when it goes to get the data through SQL, it seems like the issue is with either my ODBC settings or my ColdFusion Server Data Source Settings but I'm not familiar enough with these settings to know what needs to be changed to get this working.
A workaround was found and discussed within the comments. Adding some details here as an answer for future visitors to this page.
There are a couple of considerations when dealing with Unicode (Chinese) characters:
The data type for the database table must be set to nvarchar
The form processing script (CFML) must be set to utf-8
I believe ColdFusion defaults to this but you can specify the setting to be sure.For example: <cfprocessingDirective pageEncoding=”utf-8″>
Enable "String Format" within the ColdFusion datasource settings
Under the ColdFusion administrator datasource settings select the appropriate datasource you are using. Then click on the "show advanced settings" button. That will show an option for "String Format" Enable High ASCII characters and Unicode for data sources configured for non-Latin characters. Select this option and save the datasource.
The issue for the OP was that they were using an ODBC datasource and the "String Format" option was not available. After some research and the lack of finding any way to configure an ODBC datasource for that setting I recommended trying to use the builtin JDBC driver for "DB2 Universal Database" that comes with ColdFusion. Switching to that driver resolved this issue for the OP.
From the comments
Good info. Though is "Enable String Format..." necessary with the added support for cf_sql_nvarchar in CF10+? – #Leigh
I do believe Leigh is correct that the newer versions of ColdFusion (10 and later) have much better support for nvarchar fields.
Also to note, it looks like some older versions of ColdFusion don't always work with the installed DB2 Universal Driver, and it doesn't look like the older standard versions even have it, I'm not sure if the newer ones have it either, but using the "other" option with jt400.jar, should also work. - #MHall
You've already proven that CF can output UTF-8 characters correctly. Have you tried running that query in the DB console or UI? Do you get the correct charaters?
If the characters were stored as VARCHAR and not NVARCHAR, then there's nothing you can do. The data has to have been properly stored in the first place.
If the characters are stored correctly in the DB, try adding <cfprocessingdirective pageEncoding="utf-8"> at the top of the request. CF should be using UTF-8 by defualt, but this will force the correct character set if, for some reason, it isn't.
I have a trouble in sharepoint search.
I have dev environment and customize the Core search web part results.
The results view changed with xlst. In xslt i use HitHighlighting template for highlighting search results and jquery for replacing # symbols.
On dev environment search site work great, but when I moved my settings to test environment some functionality doesn't work.
Search works with title in query, with query includes title and some properties, but doesn't work with query includes title with some other properties.
I tried to output search raw result and all of searched properties are in raw result. But when I use query like title and one of "problem" property the raw result return empty.
Why sharepoint search returns no result on query with "problem" property and return this property in raw result with title search query.
Where can be the difference in my environments?
I resolve my problem.
At test environment I delete Search service with database from services in CA.
Then I create a new one and configured it. Search start works properly.
I have set up a custom scope in webstorm, and am trying to use it to limit search results by excluding third party libraries and such when doing 'Find in Path'. However, even though my custom scope is based on my project, I still get results in my search from outside my project. In particular, I get results from webstorm libraries and plugins:
I am using Webstorm 10.0.4
How do I filter those results out of my search results?
Known issue, IDEA-139723, please follow this ticket for updates.
To get rid of the issue, I'd suggest using 'include' filters in scope instead of 'exclude' filters - i.e. instead of excluding certain folders, just include everything you'd like being included
I want to generate a complete SQL file with Django that can be downloaded and executed to create a SQLite DB.
The problem is escaping the strings to insert them into the file to download. This is what I got so far:
name = MySQLdb.escape_string(self.name.encode("utf-8")).decode("utf-8")
return "INSERT INTO names VALUES(%d,'%s');" % (self.id, name)
But unfortunately MySQL escapes single quotes with a backslash \ which SQlite does not like. I would prefer to use something contained in Django to replace MySQLdb.escape_string(). I'm not sure if there are any other issues of incompatibility between MySQL-escaping and SQLite therefore it would be good to avoid MySQLdb.escape_string() completely.
As a last recourse I would do this before returning:
name = name.replace("\\\'","\'\'")
Any thoughts?
SQLite has the quote function for this.
It's also used by the sqlite3 command-line tool when you .dump an entire database.