AEM 6.3 Query builder - How to search for case insensitive? - aem

How can we make the query to ignore case sensitivity of the property.value ?
Our query:
path=/content/central-content/jcr:content/main/decline_letter
property.value=0091A
property=#letterNumber
type=nt:unstructured
Works for 0091A but fails for 0091a

Using fulltext seemed to be helping/working.
path=/content/central-content/jcr:content/main/decline_letter
fulltext=0091A
property=#letterNumber
type=nt:unstructured
orderby.case=ignore
fulltext may not be a good solution is we have to be searching among a lot of nodes/data. In our case, we search for a very minimal number of nodes.

Related

prometheus doesn't match regex query

I'm trying to write a prometheus query in grafana that will select visits_total{route!~"/api/docs/*"}
What I'm trying to say is that it should select all the instances where the route doesn't match /api/docs/* (regex) but this isn't working. It's actually just selecting all the instances. I tried to force it to select others by doing this:
visits_total{route=~"/api/order/*"} but it doesn't return anything. I found these operators in the querying basics page of prometheus. What am I doing wrong here?
May be because you have / in the regex. Try with something like visits_total{route=~".*order.*"} and see if the result is generated or not.
Try this also,
visits_total{route!~"\/api\/docs\/\*"}
If you want to exclude all the things that has the word docs you can use below,
visits_total{route!~".*docs.*"}
The main problem with your original query is that /api/docs/* will only match things like /api/docs and /api/docs//////; i.e. the * in your query will match 0 or more / characters.
I think what you meant to use was /api/docs/.*.

How to do case insensitive search using QueryBuilder in CQ?

I am doing CQ search using Querybuilder on a set of 8 properties. One of them is a text box. So case insensitive search needs to be done on it. All others are drop downs.
Issue: Case sensitive search is happening on the text box.
Below mentioned in piece of code. When I include case insensitive code, the search is not happening properly.
Any pointers on this will be really helpful.
map.put("1_customcase.property", searchkey);
map.put("1_customcase.property.value", searchkey);
map.put("1_customcase.case", "no_case");
map.put("orderby", "customcase");**
map.put("2_property", propertyname);
map.put("2_property.value", value);
map.put("3_property", propertyname);
map.put("3_property.value", value);
...
...
...
Query query = builder.createQuery(PredicateGroup.create(map), session);

Lucene wildcards and words with the letter 's' on the end

Im having a bit of trouble finding some information on whats happening with my lucene searches.
(Id:gloves* Search:gloves* SpellCheckerSource:gloves*) OR
(Id:gloves Search:gloves SpellCheckerSource:gloves) OR
(Id:glove* Search:glove* SpellCheckerSource:glove*)
When I search for the above I get the following rewritten term
(() () ())
(Id:glove Search:glove SpellCheckerSource:glove)
(() ConstantScore(Search:glove*) ConstantScore(SpellCheckerSource:glove*))
This is using LUKE, I have been running the query in LUKE to try see whats going on.
http://www.getopt.org/luke/
Now what I want to be able to do is search for a term ie gloves* which ends up being (() () ())
I don't understand why this gets translated like this is there and issue with my query or with my index?
LUKE tells me the structure explanation is as follows
lucene.BooleanQuery
clauses=3, maxClauses=1024
Clause 0: SHOULD
lucene.BooleanQuery
clauses=3, maxClauses=1024
Clause 0: SHOULD
lucene.BooleanQuery
clauses=0, maxClauses=1024, coord=false
Clause 1: SHOULD
lucene.BooleanQuery
clauses=0, maxClauses=1024, coord=false
Clause 2: SHOULD
lucene.BooleanQuery
clauses=0, maxClauses=1024, coord=false
Clause 1: SHOULD
lucene.BooleanQuery
clauses=3, maxClauses=1024
Clause 0: SHOULD
lucene.TermQuery
Term: field='Id' text='glove'
Clause 1: SHOULD
lucene.TermQuery
Term: field='Search' text='glove'
Clause 2: SHOULD
lucene.TermQuery
Term: field='SpellCheckerSource' text='glove'
Clause 2: SHOULD
lucene.BooleanQuery
clauses=3, maxClauses=1024
Clause 0: SHOULD
lucene.BooleanQuery
clauses=0, maxClauses=1024, coord=false
Clause 1: SHOULD
lucene.ConstantScoreQuery, ConstantScore(Search:glove*)
Filter: Search:glove*
Clause 2: SHOULD
lucene.ConstantScoreQuery, ConstantScore(SpellCheckerSource:glove*)
Filter: SpellCheckerSource:glove*
This seems strange to me on multiple levels
Why have I got translated blank clauses?
Why have I got a mix of TermQuery,ConstantScoreQuery And BooleanQuery?
Where are ConstantScoreQuery getting generated?
It should be noted everything works fine for me when i search for a term with out and s IE glove or with out a wildcard just the combination of the two seems to break the query.
This is probably happening because there are no terms in your index that match "gloves*".
When a MultiTermQuery is rewritten, it finds the Terms that are suitable, and creates primitive queries (such as TermQuery) on those terms. If no suitable terms are found, you'll see an empty query generated instead, like what you've shown.
A TermQuery is already a primitive query, and no rewriting is needed there. It doesn't have to enumerate terms or anything, it just runs the thing.
The other piece of this is analysis. Your query for gloves is getting analyzed to glove (EnglishAnalyzer perhaps?). MultiTermQueries (like wildcard, fuzzy, regex and prefix queries) are not analyzed by the QueryParser. Your prefix query is trying to find " "gloves", but all those plural s, have been stemmed away, so it doesn't find any matches.

Sphinx Search term boost

Is there a way I can add a weight to each word in my query?
I need to do something like this (Lucene query):
"word1^50|word2^45|word3^25|word4^20"
All answers I found online are old and I was hoping this changed.
UPDATE:
Sphinx introduced term boosting in version 2.2.3: http://sphinxsearch.com/docs/current/extended-syntax.html
Usage:
select id,weight() from ljplain where match('open source^2') limit 2 option ranker=expr('sum(max_idf)*1000');
No nothing really changed. The same old workarounds should still work tho.

MongoDB - searching text

What is the best strategy for selecting mongodb entries in which a string value contains a set of words or phrases? I'm thinking of something equivalent to mysql's LIKE function, e.g.
WHERE (TEXT LIKE "% apple %") or (TEXT LIKE "% banana %")
I've seen options that involve tokenizing the string, but this would involve building unigrams for all the text, which would be huge no?
Mongo now supports text search since 2.4.
My experience has been pretty positive
http://docs.mongodb.org/manual/applications/text-search/
You start the server with setParameter text search enabled
Then enable the index on the collection
Then search with runCommand
MongoDB has no full text search capability right now, but it's easy to use external search engines like SOLR.
I strongly discourage you trying to rebuild text search with Regex or word stemming etc. yourself. You should rather focus on your app own features :)
I am using this combination: Mongoid, Sunspot and Mongoid-Sunspot. It works very well in production, and development setup is easy.
You can use the regular expression support in MongoDB queries. More details available # the following link
http://docs.mongodb.org/manual/reference/operator/regex/
Here are two examples should the above link move again in the future:
db.collection.find( { field: /acme.*corp/i } );
db.collection.find( { field: { $regex: 'acme.*corp', $options: 'i' } } );
Somehow MongoDB built-in text search failed to meet my requirements on an existing database which used a compound index. I am now using mongoose-search-plugin and it has been working superbly well. It uses natural stemming, and distance algorithms to return a relevance score.
User.search('Malaysia Car Food',{username:1},{}, function(err, u){
console.log('Search Results: '+JSON.stringify(u));
});