Case insensitive in XPath constraint

2
Hi guys n gals, I'm looking for a way to make my XPath constraint case insensitive. My client can search for addresses, and I do a database lookup based on that search criteria. However, my database holds the records in the current way: 'Willem de Zwijgerweg' my client will search for ANY combination possible: willem de zwijgerweg, Willem De Zwijgerweg, Willem de zwijgerweg etc. Obviously the current way doesn't work. Is there any way to make the XPAth constraint case-insensitive, or do I need to build my retrieve differently?   Thanks in advance
asked
5 answers
8

Hi Paul,

Shouldn't this work?

[contains(straat, 'willem de zwijgerlaan')]

I thought contains was case insensitive just like the "Like" operator.

Regards,

answered
4

Hi Paul,

If you are looking for a high-performance full text search you should consider implementing Lucene. https://appstore.home.mendix.com/link/app/3099/
It allows you to search case insensitive and much more. For example, in your case the following queries would all work:

"Willem Zwijgerweg" //ommiting a word

"de zwijgErweg willem"  //mixing up the order of the words and the case

"zwijgErweg willem" //mixing up the order and the case and ommitting


I think you get the point.
If you think this is a bit of an overkill, I would go for a simple workaround to introduce a second attribute where you store the name in all lowercase (or all uppercase). Then when you search you also make sure to convert the query term to lowercase (or uppercase). Unless you have millions of records I wouldn't worry about database memeory.

-Andrej
 

answered
3

Just tried this and indeed contains is case insensitive, just like Corné Hoogendoorn said

[contains(straat, 'Willem de Zwijgerweg')]
answered
3

Is it possible for Mendix implementing the following XPath functionnalities :
lower-case()
upper-case()

and translate().

it will be more simple for everybody

answered
0

I tried  [string-length(Name) = string-length($object/Name) and contains(Name, $object/Name)]. 

 

Example : 

$object/Name =[‘Ana’,’anlus’]       ---     Name=ana

Result : ‘’Ana’

answered