Start a new topic
Answered

Wildcard searches using the REST API

Can I use wildcard for searches using the REST API?


Best Answer

The details in this article were culled from this doc where a variety of ways to query your data via the REST API are spelled out in some detail. In addition, there is a new, very good, tutorial on the same subject located here.

For my instance I was able to create this filter which acts as a wildcard search. I recommend the upper as it will remove the case sensitivity of your search. You would need to replace the IP address, data location and entity name with your own. This query is looking for Golden Company records like ‘HARLEY’.

http://13.56.77.82/semarchy/api/rest/query/DLOC2/Company/GD/?$f=Upper(CompanyName)%20LIKE%20%27HARLEY%25%27


To add additional parameters, it would look like this:

http://13.56.77.82/semarchy/api/rest/query/DLOC2/Company/GD/?$f=Upper(CompanyName)%20%20like%20%27%25GENERAL%25%27%20and%20Upper(RawAddress.StateProvince)%20%20like%20%27%25MI%25%27


This query is looking for Golden Companies with a name like ‘General’ and a state like ‘MI’ The fastest way to determine how your query should look is to go to the application and apply a filter to a Browse Business View action. If you're looking at a Browse Business View action in the app you'll see an filter icon in the upper right corner, it looks like this: 

Click that and for search type select SemQL, in the filter condition, create your wildcard query, or any query for that matter. Here I filtered on company name like 'General' and state like 'MI'. 

When you apply this filter, you will see how it needs to be rendered to include the control characters so it can be sent to the rest API. In the resulting URL you will see something like this:

Everything inside the double quotes after "semqlCondition" is what you'll need to send to the API using the ?$f= syntax that I show above. Alternatively, you can google each control character you need and build your query using them directly. For example, we can infer that:

  • %20 is a space
  • %27 is a single quote
  • %25 is a % sign (somewhat ironically, I might add)

and so on.


One note: when building my query in the app I was tempted to use the column name, 'State Province' in my case, but you have to use the actual column name, not the display name and not the name of the column in the database, all of which are often different.

1 Comment

Answer

The details in this article were culled from this doc where a variety of ways to query your data via the REST API are spelled out in some detail. In addition, there is a new, very good, tutorial on the same subject located here.

For my instance I was able to create this filter which acts as a wildcard search. I recommend the upper as it will remove the case sensitivity of your search. You would need to replace the IP address, data location and entity name with your own. This query is looking for Golden Company records like ‘HARLEY’.

http://13.56.77.82/semarchy/api/rest/query/DLOC2/Company/GD/?$f=Upper(CompanyName)%20LIKE%20%27HARLEY%25%27


To add additional parameters, it would look like this:

http://13.56.77.82/semarchy/api/rest/query/DLOC2/Company/GD/?$f=Upper(CompanyName)%20%20like%20%27%25GENERAL%25%27%20and%20Upper(RawAddress.StateProvince)%20%20like%20%27%25MI%25%27


This query is looking for Golden Companies with a name like ‘General’ and a state like ‘MI’ The fastest way to determine how your query should look is to go to the application and apply a filter to a Browse Business View action. If you're looking at a Browse Business View action in the app you'll see an filter icon in the upper right corner, it looks like this: 

Click that and for search type select SemQL, in the filter condition, create your wildcard query, or any query for that matter. Here I filtered on company name like 'General' and state like 'MI'. 

When you apply this filter, you will see how it needs to be rendered to include the control characters so it can be sent to the rest API. In the resulting URL you will see something like this:

Everything inside the double quotes after "semqlCondition" is what you'll need to send to the API using the ?$f= syntax that I show above. Alternatively, you can google each control character you need and build your query using them directly. For example, we can infer that:

  • %20 is a space
  • %27 is a single quote
  • %25 is a % sign (somewhat ironically, I might add)

and so on.


One note: when building my query in the app I was tempted to use the column name, 'State Province' in my case, but you have to use the actual column name, not the display name and not the name of the column in the database, all of which are often different.

Login to post a comment