Question

How to create an Endeca query on combination of multiple fields [just like where clause in sql query]. Suppose we have three fields indexed are -

  1. empId
  2. empName
  3. empGender

Now, I need a query like "where empName like 's%' AND empGender=male"

Thanks.

Was it helpful?

Solution

Firstly,

Checkout Record Filters in the Advanced Development Guide.

If you are trying to use a Record Filter on a property, you will need to enable it explicitly in Developer Studio for that property, while your Dimensions will automatically have the ability to apply a Record Filter. This will help when you have explicit values to filter on, for example empGender.

Your Record Filter can then look as follow:

Nr=AND(empGender:male)

You can further use the Ntk parameter to specify fields to search on so assuming your empName field is enabled for wildcard searching (configure this in Developer Studio) searching this field will look as follow:

Ntk=empName&Ntt=s*

So assuming your properties have been configured correctly, your example above will probably end up looking as follow:

Nr=AND(empGender:male)&Ntk=empName&Ntt=s*

To take this one step further, you can specify Search Filters (ie. Ntk + Ntt parameters) together. I haven't tried this for wildcards so you'll need to confirm that yourself but to combine Search Filters you delimit them with |

Ntk=empName|empId&Ntt=s*|1234*

I suggest you manually build up queries in the Reference Application to confirm you get your expected results and then start to code this up in your application.

OTHER TIPS

radimbe, the problem with record filters for this use case is that they need to be precise. This means you don't get pelling correction, thesaurus expansion, case insensitivity or stemming. It's very unlikely that a user will input precise information like this.

Saraubh, you can do a boolean search to do OR text search queries. You can also use the Endeca Query Language to specify a complex set of boolean logic that goes beyond boolean search and which would incorporate spelling correction, stemming, etc.

In general though, I think for an application like this, you should move away from searching specific individual fields simultaneously and make use of the faceting capabilities of dimensions to guide the user. Additionally, a search box that searches many fields in combination simultaneously in order of importance is really the way to go for a simplified user interface for this sort of application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top