non-case sensitive search function

3103
7
Jump to solution
09-11-2014 01:12 PM
CONABIONC_for_Knowledge_and_Us
Occasional Contributor

Dear all,

We are working on a web-map with an integrated search function (built on the ArcGIS API for JavaScript), based on county names, which are requested from a feature service - here the map:

Cruzada Nacional contra el Hambre en Oaxaca

The function works fine, but just when you put the names exactly like they are written in the feature service. Is there a way to define a non-case sensitive search function?

E.g.

  • Case 1)  Santa Ana Tavela > 1 result
  • Case 2) St. Ana Tavela > 0 results
  • Case 3) Sant Ana Tavela > 0 results
  • Case 4) Ana Tavela > 0 results

How can we define a more flexible search function that also responds to case 2-4?

Thank you & best regards,

Flo

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
AnthonyGiles
Frequent Contributor

Flo,

reading your question again it's not really just a case of searching for case sensitivity, you would be better using a like statement to search for a particular word:

query.where = "NOM_MUN LIKE '%"+ campo +"%'";

this will allow you to type in Tavela and get a result

I'm still not seeing a search bar in IE11:

View solution in original post

7 Replies
AnthonyGiles
Frequent Contributor

Flo,

You have not tagged your question so it is hard to know what application, language you are referring to.

If your are you using a SQL statement as you could add an upper or lower function to convert the case so that they will be the same, e.g:

UPPER(Name) = UPPER(Value)

0 Kudos
CONABIONC_for_Knowledge_and_Us
Occasional Contributor

Thank you Anthony, it´s the ArcGIS JavaScript API - I´ve updated the question.

0 Kudos
AnthonyGiles
Frequent Contributor

I cannot see any search function on the link you have posted up.

Are you building up a SQL command to that is passed to the server? If so just build in the UPPER functions above into your SQL

0 Kudos
CONABIONC_for_Knowledge_and_Us
Occasional Contributor

Mhhh ... well there is a ComboBox"Seleccione un municipio" (next to the zoom in/out) button, where you can select/search counties.

The query is build like this;

var query = new esri.tasks.Query();

query.where = "NOM_MUN = '"+ campo +"'";

NOM_MUN contains the county names.

thank you,

Flo

0 Kudos
AnthonyGiles
Frequent Contributor

Flo,

reading your question again it's not really just a case of searching for case sensitivity, you would be better using a like statement to search for a particular word:

query.where = "NOM_MUN LIKE '%"+ campo +"%'";

this will allow you to type in Tavela and get a result

I'm still not seeing a search bar in IE11:

CONABIONC_for_Knowledge_and_Us
Occasional Contributor

Thank you very much for the hint and for clarifying the issue. Our programmer will give it a try, than we´ll update the thread  ...

cheers,

Flo

P.S.: It works here also in IE11 - you just have the wait until the map is loaded completely.

0 Kudos
CONABIONC_for_Knowledge_and_Us
Occasional Contributor

Hi Anthony,

LIKE works fine - thank you very much!

However, we would like, that the combobox shows the same behaviour, i.e. that it lists all counties that contain a name´s part - but I guess that´s a dojo/dijit issue, so we´ll close this thread with "answered".

0 Kudos