full-text-search

Is it possible to persist a joined field in Djangos SearchVectorField?

丶灬走出姿态 提交于 2020-05-13 07:48:07
问题 Is it possible to persist a joined field with Djangos SearchVectorField for full text search? For example: class P(models.Model): brand = models.ForeignKey(Brand, on_delete=models.CASCADE) search_vector = SearchVectorField(null=True, blank=True) code: p = P.objects.get(id=1) p.search_vector = SearchVector('brand__name') p.save() raises this exception: FieldError: Joined field references are not permitted in this query If this is not possible how can you increase the performance of joined

Locate popular strings with PostgreSQL

余生长醉 提交于 2020-05-11 02:57:32
问题 I have a bunch of text rows in a PostgreSQL table and I am trying to find common strings. For example, let's say I have a basic table like: CREATE TABLE a (id serial, value text); INSERT INTO a (value) VALUES ('I go to the movie theater'), ('New movie theater releases'), ('Coming out this week at your local movie theater'), ('New exposition about learning disabilities at the children museum'), ('The genius found in learning disabilities') ; I am trying to locate popular strings like movie

Locate popular strings with PostgreSQL

无人久伴 提交于 2020-05-11 02:57:19
问题 I have a bunch of text rows in a PostgreSQL table and I am trying to find common strings. For example, let's say I have a basic table like: CREATE TABLE a (id serial, value text); INSERT INTO a (value) VALUES ('I go to the movie theater'), ('New movie theater releases'), ('Coming out this week at your local movie theater'), ('New exposition about learning disabilities at the children museum'), ('The genius found in learning disabilities') ; I am trying to locate popular strings like movie

Django MySql Fulltext search works but not on tests

瘦欲@ 提交于 2020-04-30 07:16:06
问题 I used this SO question to enable full text search on a mysql db in Django application. # models.py class CaseSnapshot(BaseModel): text = models.TextField(blank=True) class Search(models.Lookup): lookup_name = "search" def as_mysql(self, compiler, connection): lhs, lhs_params = self.process_lhs(compiler, connection) rhs, rhs_params = self.process_rhs(compiler, connection) params = lhs_params + rhs_params return f"MATCH (%s) AGAINST (%s IN BOOLEAN MODE)" % (lhs, rhs), params models.TextField

Spring boot RestHighLevelClient Elastic Search on combine queries

纵饮孤独 提交于 2020-04-18 05:48:12
问题 I have a domain public class Person { private String name; private String description; private Long positionId; // ---- other props ------ } and I want to search for query string on field name, description and positionId I can make it works by using BoolQueryBuilder but It is not working on _score final BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder(); final QueryBuilder queryBuilder = QueryBuilders.queryStringQuery("query text"); boolQueryBuilder.filter(queryBuilder);

PostgreSQL full text search abbreviations

筅森魡賤 提交于 2020-04-16 11:48:12
问题 I created a Postgresql full text search using 'german'. How can I configer, that when I search for "Bezirk", lines containing "Bez." are also a match? (And vice-versa) 回答1: @pozs is right. You need to use a synonym dictionary. 1 - In the directory $SHAREDIR/tsearch_data create the file german.syn with the following contents: Bez Bezirk 2 - Execute the query: CREATE TEXT SEARCH DICTIONARY german_syn ( template = synonym, synonyms = german); CREATE TEXT SEARCH CONFIGURATION german_syn(COPY=

PostgreSQL full text search abbreviations

£可爱£侵袭症+ 提交于 2020-04-16 11:47:40
问题 I created a Postgresql full text search using 'german'. How can I configer, that when I search for "Bezirk", lines containing "Bez." are also a match? (And vice-versa) 回答1: @pozs is right. You need to use a synonym dictionary. 1 - In the directory $SHAREDIR/tsearch_data create the file german.syn with the following contents: Bez Bezirk 2 - Execute the query: CREATE TEXT SEARCH DICTIONARY german_syn ( template = synonym, synonyms = german); CREATE TEXT SEARCH CONFIGURATION german_syn(COPY=

Spring Data mongo case insensitive like query

自作多情 提交于 2020-04-08 09:23:25
问题 I want to make a text search case insensitive with regex query with spring-data mongo . For example in Oracle : select * from user where lower(username) like '%ab%' How can i make this query with spring-data mongo ? Thanks in advance 回答1: You can try something like below. Assumes you have a User pojo class. Using MongoTemplate i option for case insensitive: Criteria regex = Criteria.where("username").regex(".*ab.*", "i"); mongoOperations.find(new Query().addCriteria(regex), User.class); Using

Use Full Text Search for Persian Language

非 Y 不嫁゛ 提交于 2020-03-18 15:22:27
问题 I see supported language in full text search (SQL Server 2012). Persian (Farsi) does not exist in list. But as I know, there is a way to use full text search for Persian language with adding custom dictionary, using Arabic language and etc. Please help and give me some references and guidance for using Persian language in Full Text Search of SQL Server 2012. 回答1: Yes FTS doesn't support Persian language, but that doesn't mean it won't work with it. Only inflectional queries such as WHERE

Escaping special characters in to_tsquery

无人久伴 提交于 2020-02-20 06:37:23
问题 How do you espace special characters in string passed to to_tsquery ? For instance, this kind of query: select to_tsquery('AT&T'); Produces: NOTICE: text-search query contains only stop words or doesn't contain lexemes, ignored to_tsquery ------------ (1 row) Edit: I also noticed that there is the same issue in to_tsvector . 回答1: If you want 'AT&T' to be treated as a search word, you're going to need some customised components, because the default parser splits it as two words: steve@steve@