mardi 30 novembre 2021

How to design a keyword's search in api - by api or procedure in database

I designed a simple page where I display records from the database. They are downloaded via api written in the asp.net core. Each record has a column where it's just a json string with different fields and values. The number of fields in json is dynamic. I don't know in advance how many there will be. I wanted to make a search engine that would search all fields in json right away - does not indicate the field in the search engine. I am generating the appropriate api string with the passed values ​​from the search engine. Api receives it. Now I have a problem. Should the search engine in this case be done only on the api side? Or also on the database side with the use of views and procedures with dynamic query.

1st version is like this:

  • Api receives a string like this:
http://mypage/api/search?keywords=James&keywords=Doe

Api must download the entire data set and then filter it in a loop using the selected keywords. So I think it's not good idea in this form.

2nd version I was thinking about: Api calls a procedure in the database, which after passing parameters, calls a dynamic query like:

Select * from Documents where Json
 like '% James%' and Json like '% Doe%' 



Aucun commentaire:

Enregistrer un commentaire