cancel
Showing results for 
Search instead for 
Did you mean: 

Query (GET_ENTITYSET) entity on fields not in the entity structure

jayesh_vorani1
Explorer
0 Kudos

Hello Friends,

I have a specific requirement to search based on fields that are not necessarily the part of entity whose records I am expecting back in the result set.


Obviously for $filter to work, the field to be searched on should be part of the entity structure, but the field doesn't quite belong to the entity in its pure form.


Just to make it clear with an example... let us say I want to search for customer records but based on MPRN field (Meter Point Reference Number) which really should belong to Meter entity instead of customer entity. If the field does not belong to customer entity, I can't pass this search field in the url using $filter on Customers entity.


This (I think) leaves me with 2 options...


  1. Add this MPRN field to customer entity so that I can pass it as a $filter parameter to customer entity. Here I pollute the customer entity with a search field which really does not belong to customer entity. OR
  2. Create a new entity named customer search and have Customer Id and MPRN id as its fields. Create a navigation property between this new entity and customer entity. Then query on new entity passing $filter for MPRN and do $expand to the customer entity.

If this has made any sense, can I request for some recommendation between the above 2 options or even a third and a better option may be?

Kind Regards,

Jay


Accepted Solutions (1)

Accepted Solutions (1)

former_member184867
Active Contributor

Another possible option would be to use OpenSearch, in fact this is the easiest way to achieve the requirement.

If you do not know much about this, you can have a look at Home - OpenSearch.

OpenSearch is suitable for situations where you want to perform  free search based on a search template without bothering much about the entity Structure. It is a very old feature available from SP4. Eventhough you do not find much documentation on it, it is just a 'button click' on SEGW without much work.

Step to perform

In transaction SEGW,  for your entity select the  'Searchable' checkbox like the picture below

(and you are done).You will find much more information in the F1 help documentation.

How to check it ?

Now if you run the metadata, you will find the url of the search   template

If you visit the url http://<service url>/<openserach_href>, where  <openserach_href> is the href highlighted above, you get the search template like the below one,

The template describes how one can perform an free search on entity set 'testSet'. For example, if you use the url,

https://<SERVICEURL>/testSet?search=anything i want to search

You get the search value in GET_ENTITYSET method of your Data Provider Class, in parameter IV_SEARCH_STRING. Here you are free to use your search string to select anything and return the data.

I think this can be used for your scenario.

Regards,

AM

kammaje_cis
Active Contributor

Thanks Atanu. This is definitely easier and better way.

Answers (2)

Answers (2)

jayesh_vorani1
Explorer
0 Kudos

Krishna / Atanu,

Many thanks for your responses.

Atanu - I agree openserch is the best approach to tackle the scenario I described.

Kind Regards,

Jay

kammaje_cis
Active Contributor
0 Kudos

Jayesh,

I would prefer a Function import in this case. Function Import can take the URL parameters (your search term) and return an entity set.

Regards

Krishna