I want to index a JSON(string) as vertex-centric index. My use case is that I want to match regex predicates in this string. Will vertex-centric indexes support textRegex
I am following this link for checking string search in Janus: https://docs.janusgraph.org/index-backend/search-predicates/#text-predicate
For example: If my string property is {"foo":"bar"}, I want to regex search for property "foo" in this string property.
Related
I have this string here I need to split up in tokens.
thorak={name="Thorak"}
The result should look something like this:
["thorak", "=", "{", "name", "=", "Thorak", "}"]
My thought
I thought about having different RegEx rules running over it but am a bit unsure how to do this properly.
Consider this rule array:
["^(\w+)", "^=", "^{", "^(\w+)", "^=", "^(\w+)", "^}"]
Given a RegEx rule that only matches Strings ^(\w+) I would apply it to the string.
It should match with the thorak string and there I have my first token.
To have this work in a loop I might do the following:
Match a RegEx rule
Save the matching string in an array
Remove the matching string from the iterated string (to have RegEx rules running over the next parts)
Repeat until the String is empty OR no rule was able to be applied
This is my first time doing a bit more labor work on string so I wonder what nifty tricks there exist to make what I want easier.
Do we have any methods in mel to check string contained in some another String or not.
For Example:
I had String like "mel".
I had Another String like "melcode".
Do we have any idea how to check the String "mel" is available in String "melcode".
num indexOf(str inputString1, str inputString2)
if the return value is -1 then inputString1 does not contain inputString2
As mentioned in Is there any possible way to filter movelets using mel from another movlet?
Hi Jaya Sankar, you can use indexOf which returns -1 if the first input String does not contain the second input String. There are also startsWith and endsWith as methods.
I am trying to check if a key of a map in freemarker matches a particular string. How can I do that?
<#if (list_map.id)!?matches(("abc"))>
you matched ...
</#if>
but the above doesn't work in freemarker. It says matches expects a string. How can I convert list_map.id to a string ? is there any toString() method available in freemarkeR?
If id is a number, then probably you want list_map.id?c to render it to computer-format string.
I have created a text index on the num field in the collection. Now while passing the string to search from the text index, I need to use a regex which has to be passed as a string to the $search variable.
My current query works fine but it doesn't work when I add a regex to it.
Current Query:
db.collection.find({$text:{$search:"1234 6789"}},{'id':1})
I need to add a regex/like query to the $search to make it something like
db.collection.find({$text:{$search:"/1234/ /6789/"}},{'id':1})
where I get all the values from the database that contain a pattern like "1234" OR "6789".
I did try the query but it gives me a $search needs a String error:
db.collection.find({$text:{$search:/1234/}},{'id':1})
To achieve this you should use the $regex MongoDB operator:
// Without options
db.collection.find({num: /1234|5678/i});
// Separate options property
db.collection.find({num: {$regex: /1234|5678/, $options: 'i'}});
To add multiple terms in the regex, use the | operator
$regex docs and examples
Edit:
For querying records using an array of values the $in operator can be used:
$in docs and examples
Is there a way when using Sitecore Search and Lucene to not match partial words? For example when searching for "Bos" I would like to NOT match the word "Boston". Is there a way to require the entire word to match? Here is a code snippet. I am using FieldQuery.
bool _foundHits = false;
_index = SearchManager.GetIndex("product_version_index");
using (IndexSearchContext _searchContext = _index.CreateSearchContext())
{
QueryBase _query = new FieldQuery("title", txtProduct.Text.Trim());
SearchHits _hits = _searchContext.Search(_query, 1000);
...
}
You may want to try something like this to get the query you want to run. It will put the + in (indicating a required term) and quote the term, so it should exactly match what you're looking for, its worked for me. Providing you're passing in BooleanClause.Occur.MUST.
protected BooleanQuery GetBooleanQuery(string fieldName, string term, BooleanClause.Occur occur)
{
QueryParser parser = new QueryParser(fieldName, new StandardAnalyzer());
BooleanQuery query = new BooleanQuery();
query.Add(parser.Parse(term), occur);
return query;
}
Essentially so your query ends up being parsed to +title:"Bos", you could also download Luke and play around with the query syntax in there, its easier if you know what the syntax should be and then work backwards to see what query objects will generate that.
You have to place the query in double quotes for the exact match results. Lucene supports many such opertators and boolean parameters that can be found here: http://lucene.apache.org/core/2_9_4/queryparsersyntax.html
It depends on field type. If you have memo or text field then partial matching is applied. If you want exact matching use string field instead. There you can find some details: https://www.cmsbestpractices.com/bug-how-to-fix-solr-exact-string-matching-with-sitecore/ .