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
6 answers
10

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

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

and translate().

it will be more simple for everybody

answered
3

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

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

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
2

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

 

Example : 

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

Result : ‘’Ana’

answered
0

Another option, depents on how big the databse entity is…

For example you want to look for Willem de Zwijgerlaan in the database:

 

  1. Make a variable, which will make the search attribute to Upper (WILLEM DE ZWIJGERLAAN) and name it $STRAATNAAM_UPPER
  2. Retrieve all from entity 
  3. Filter List by Expression
  4. Expression = toUpperCase($currentObject/<STRAATNAAM>) = $STRAATNAAM_UPPER

 

This will return a list of all foun objects.

This works perfectly for the following cases:

- You already retrieve all the attributes
- The entity does not have too many rows (or you don't care about performance)
- with the filter by expression you have tons of posabilities :))

 

 

answered