full-text-search

RegEx to replace text between two hash-symbols, between two tags, but keep everything else

99封情书 提交于 2020-01-14 14:16:07
问题 So I need to replace #var# and #var2# with <cfqueryparam value="#var#" /> and <cfqueryparam value="#var2#" /> . However, this should only happen when #var# is wrapped inside <cfquery></cfquery> . As an extra criteria, the cfquery-tag will contain text before and after the hash-symbols. This is an example: <cfquery datasource="#tablename#"> SELECT * FROM table WHERE name = #var#, somethingelse = #var2#; </cfquery> I need a regex that only matches 'test' when it's between two hash-symbols and

Index Word/PDF Documents From File System To SQL Server

萝らか妹 提交于 2020-01-14 10:12:20
问题 I'm trying to come up with a simple solution to a problem I have because all of those I have found so far just seem too complicated! The situation is that we use a proprietary application for managing most aspects of our business. It has an SQL Server 2005 backend database, which is quite large. The application also allows the attaching of Word and PDF documents to records, which we use extensively, and these are stored in the file system on the server, with the filenames referenced in the

Django SearchVector on choices field

扶醉桌前 提交于 2020-01-14 04:51:05
问题 If I have a simple Django model like: from model_utils import Choices class Art(models.Model): CATEGORIES = Choices( (1, 'DIGITAL_ART', 'Digital Art'), (2, 'MULTIMEDIA', 'Multimedia'), ) title = models.TextField() category = models.PositiveSmallIntegerField( db_index=True, choices=CATEGORIES, blank=True, null=True ) How can I use SearchVector in postgres to allow for searching on both the title and categories fields? E.g. so "Some Book Digital Art" would query over both the title and

How to parse user search string for Postgresql query?

浪子不回头ぞ 提交于 2020-01-14 04:08:57
问题 i created a search engine on my site using full text search in Postegresql. i added a searchbox in my PHP page in which users can write strings like these: word1 +word2 word1+word2 word1 -word2 word1-word2 word1 word2 word1 word2 how to convert them to the following strings? word1&word2 word1&word2 word1&!word2 word1&!word2 word1|word2 word1|word2 i tried several solutions but none works with all cases. The last one i tried is the following: $user_query_string = trim($_GET['search']); $final

How to insert a text file into a field in PostgreSQL?

喜夏-厌秋 提交于 2020-01-14 03:28:19
问题 How to insert a text file into a field in PostgreSQL? I'd like to insert a row with fields from a local or remote text file. I'd expect a function like gettext() or geturl() in order to do the following: % INSERT INTO collection(id, path, content) VALUES(1, '/etc/motd', gettext('/etc/motd')); -S. 回答1: The easiest method would be to use one of the embeddable scripting languages. Here's an example using plpythonu: CREATE FUNCTION gettext(url TEXT) RETURNS TEXT AS $$ import urllib2 try: f =

How to access an FTS table in SQLite.swift using the IN condition

ぐ巨炮叔叔 提交于 2020-01-13 18:07:27
问题 I'm trying to query an FTS table using SQLite.swift. Previously I have done it in Android. The essence of what I am trying to do is this: SELECT * FROM t2 WHERE id IN (SELECT docid FROM fts_table WHERE col_text MATCH 'something') From the SQLite.swift documentation I see the IN condition can be written like this: users.filter([1, 2, 3, 4, 5].contains(id)) // SELECT * FROM "users" WHERE ("id" IN (1, 2, 3, 4, 5)) And virtual tables can be queried like this: let wonderfulEmails = emails.match(

How to access an FTS table in SQLite.swift using the IN condition

我怕爱的太早我们不能终老 提交于 2020-01-13 18:06:45
问题 I'm trying to query an FTS table using SQLite.swift. Previously I have done it in Android. The essence of what I am trying to do is this: SELECT * FROM t2 WHERE id IN (SELECT docid FROM fts_table WHERE col_text MATCH 'something') From the SQLite.swift documentation I see the IN condition can be written like this: users.filter([1, 2, 3, 4, 5].contains(id)) // SELECT * FROM "users" WHERE ("id" IN (1, 2, 3, 4, 5)) And virtual tables can be queried like this: let wonderfulEmails = emails.match(

Multiple synonym dictionary matches in PostgreSQL full text searching

时光毁灭记忆、已成空白 提交于 2020-01-13 11:20:07
问题 I am trying to do full text searching in PostgreSQL 8.3. It worked splendidly, so I added in synonym matching (e.g. 'bob' == 'robert') using a synonym dictionary. That works great too. But I've noticed that it apparently only allows a word to have one synonym. That is, 'al' cannot be 'albert' and 'allen'. Is this correct? Is there any way to have multiple dictionary matches in a PostgreSQL synonym dictionary? For reference, here is my sample dictionary file: bob robert bobby robert al alan al

PSQLException: ERROR: syntax error in tsquery

北战南征 提交于 2020-01-12 04:33:06
问题 Which characters must be avoided to make sure PSQLException: ERROR: syntax error in tsquery will not occur? The documentation does not say anything about how to escape the search string: http://www.postgresql.org/docs/8.3/static/datatype-textsearch.html 回答1: Use quotes around your terms if you want them as phrases/verbatim or they contain characters used in the syntax: select to_tsquery('"hello there" | hi'); Bare in mind that you shouldn't really have crazy characters in your terms, since

Escape double quotes in SQL 2005/2008

狂风中的少年 提交于 2020-01-10 05:19:20
问题 I have an international company that has recently been added, which is named "BLA "BLAHBLAH" Ltd. (The double quotes are part of the name. ) Whenever a user tries to search for this company, by entering "Blah, or something to that affect, the search fails with a syntax error in SQL server. How can I escape this so the search will not fail? Sample SQL: SELECT c.companyID, c.companyName, c.dateAdded, count(cm.maxID) as NumDirect FROM RussoundGeneral.dbo.Company c LEFT JOIN RussoundGeneral.dbo