Searching for string in string in Couchbase - go

I'm using the GO SDK to search my Couchbase database. I have this exact match query working:
qp.And(cbft.NewConjunctionQuery(cbft.NewMatchQuery("garden").Field("Features")))
But I want to do use a 'LIKE' query instead. For example, find "garden" in this string "driveway, garden, shed".
How do I do that in Go?

Related

Changing the token length of Spring Boot Elasticsearch pattern matching size

I am using Spring Boot and Elasticsearch and I am trying to use three character searches but the searches only match on five characters or more.
If I have a user name of 'Bob Smith' I can find the match searching for 'Smith' but searching for 'Bob' does not find a match.
I suspect this is something that needs to be changed in my class ''SearchMappingConfig implements HibernateOrmSearchMappingConfigurer'' but I can't find any information about changing the size of the tokens needed to successfully match a result.
My ''#Entity'' tables have ''#FullTextField(analyzer = "english")'' annotations on the fields I want included in the token searches.
How do I change the length of the search match?
Ideally I would like any three letters to form a match, so a search for 'Ron' would match 'Ronald' and 'Laronda'
Elasticsearch 7.14
Spring Boot 2.7.6
I have been reading Spring Boot and Elasticsearch documentation but cannot find any information about changing the match length.
Hibernate is able to use an Elasticsearch or Lucene client. Our existing project uses Lucene and it would have been a large undertaking to replace that.
The recommended solution is to create new analyzers so that incoming data creates smaller tokens, I didn't want to change analyzers on my existing database.
A lot of the documentation I was able to find pointed to using the Elasticsearch query builder or the Hibernate 5 method of using a wildcard.
I tested our Elasticsearch and found that the wildcard solution would work.
I ended up using the Hibernate 6 method for wildcard searching and it works well.
SearchResult<DataClass> result = searchSession.search(DataClass.class)
.where(f -> f.wildcard()
.fields(
"firstname",
"lastname",
"username",
"currentLegalName")
.matching("*"+searchText.toLowerCase()+"*"))
.fetch(10);
long totalHitCount = result.total().hitCount();
logger.debug("Search results size {}", totalHitCount);

Elastic search query string shows documents that do not have specified key

In version 6.7.1 elastic search, I am using the query string to get some documents. After executing the query string, in addition to the actual documents, it gives those documents also which does not have the key against which data is filtered.
This was not the case when I was using 6.4.2 elastic version. The official site does not have any information regarding that.
My query looks like -
"* AND ( properties.foreignKeys.referenceTableId :(file_datatypes) OR properties.primaryKeyMetadata.referenceTables :(file_datatypes) )".
It shows the documents that has properties.foreignKeys: null and properties.primaryKeyMetadata: null, in json
Any update will be helpful.

Wildcard phrases with slop using string query in elasticsearch

Elastic supports slop for simple phrases, like "quick fox"~2, but when wildcards are used in string, it doesn't work: "qui* fox"~2
I've found a workaround for this using json query dsl using span_near and match prefix: http://grokbase.com/t/gg/elasticsearch/146vmnsj7r/workaround-for-using-wild-cards-in-phrases-and-proximity-searches-elastic-search
The thing is that I must allow users to make such queries using string query. Is there any other workaround that uses just query string syntax or maybe there's some way to extend query string syntax for this specific use case?
Thank you

Elasticsearch "Query string" query on Geo?

I'm trying to do a query on Elasticsearch using the query string interface on a Geolocation. Specifically, I am trying to return all documents within a circle (point with radius). This is clearly possible using the full query DSL based on JSON. However, I can't find the syntax for the same search using query strings in the docs here:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax
Does this mean geo queries are not supported by query string queries?
Thanks
No. It's not supported as far as I know.

How to make full text search with mongodb spring data?

Before asking this question, I have searched much about my problem. I need to make full text search from mongodb in spring framework. Up to now I just tried something with regex, but it does not cover my requirement. For example, I have a search string as 'increased world population' , and my search algorithm should return documents well-matched to search string or documents including at least one word from search string. I know Lucene does full text search, but I don't know how to implement it with my mongodb spring data and I dont know whether spring data already offer full text search. I need a tutorial which explain that.
what I have done up to now:
Criteria textCriteri = Criteria.where("title").regex(searchStr.trim().replaceAll(" +", " "), "i");
Query query = new Query(locationCriteria).addCriteria(textCriteri).limit(Consts.MONGO_QUERY_LIMIT);
List<MyObject> advs = mongoTemplate.find(query, MyObject.class);
You can create a 'text' index in mongodb and search through that, see http://docs.mongodb.org/manual/core/index-text/
Depending on your search queries, you probably want to use a more powerful search engine like ElasticSearch (as you mentioned Lucene).

Resources