Reputation: 17562
I'm using the following class mapped as a Neo4j node:
public class Item
{
public long Id { get; set; }
public string Name { get; set; }
public string[] Synonyms { get; set; }
}
The idea is that database searches should match against the Name property, or any item in the Synonyms array:
The following search performs case-sensitive matches (clipped for brevity):
START (...) WHERE item.Name = "searchTerm") OR ("searchTerm" IN item.Synonyms!) RETURN item;
I'm attempting to perform case-insensitive matches, but only got as far as this:
START (...) WHERE item.Name =~ '(?i)searchTerm') OR ("searchTerm" IN item.Synonyms!) RETURN item;
Is it possible to perform case-insensitive matches against the Synonyms string array?
Upvotes: 2
Views: 1167
Reputation: 17562
I resorted to this, which seems to do the trick:
WHERE item.Name =~ '(?i)searchTerm') OR (ANY(s IN item.Synonyms! WHERE s =~ '(?i)searchTerm')
Upvotes: 4
Reputation: 10346
You could use the str()
function:
WHERE str(item.Synonyms) =~ '(?).*whatever.*'
Upvotes: 2