manticoresearch-javascript icon indicating copy to clipboard operation
manticoresearch-javascript copied to clipboard

Compatibility issue with the other official client libraries

Open mustafa519 opened this issue 1 year ago • 2 comments

Hello!

I've recently moved from PHP to node.js. I have never used manticoresearch on the production however, it'll definitely be my main search database after a long research. My first impression was very promising with the PHP client. But I see the JavaScript/Node.js client looks pretty confusing.

I think it's definitely possible to implement the same API design as PHP client. Do you guys have any plans to implement the same API design for the JS client too?

On the other hand, without Typescript it's really hard to use the API, which is a downside for a better DX.

I am not a JS pro nor who is an experienced much developing an open source project but still I'd help in my free time as much as I can.

Thanks.

mustafa519 avatar Feb 05 '24 14:02 mustafa519

Hello @mustafa519

I think it's definitely possible to implement the same API design as PHP client. Do you guys have any plans to implement the same API design for the JS client too?

The point is that unlike the PHP client, the others are auto-generated using OpenAPI generator and the JSON protocol schema - https://manual.manticoresearch.com/Openapi#OpenAPI-specification . It allows us maintain the clients easier: when we need to propagate a new feature we just update the schema and rebuild the clients, but it comes with limitations - we can't fine-tune a specific client's behaviour as we wish. We maintain just a couple patches.

Is there any specific thing you don't like in the Javascript client compared to the PHP client?

On the other hand, without Typescript it's really hard to use the API, which is a downside for a better DX.

What do you mean? Have you tried https://github.com/manticoresoftware/manticoresearch-typescript ?

sanikolaev avatar Feb 05 '24 15:02 sanikolaev

Oh, I didn't think there is another JS client repo. I miss the TS repo, that was my bad. There is also async support as well.

I'll test and will share my experiences. But at the first sight, they both seem closer now!

My point was about specially the below implementation:

var searchRequest = new Manticoresearch.SearchRequest();
searchRequest.index = "test";
searchRequest.fulltext_filter = new Manticoresearch.QueryFilter('Star Trek 2');

So, I was rather imagining this:

import Manticore from 'manticoresearch'; 

const api = new Manticore({
  endpoint: 'http://localhost:9308"',
  // agent: ....
});

// createSearch creates the instance in the background to use it later as well, instead of
// using new SearchApi() So, we're usually going to use one request in the logic
//  but still it can be reusable again if it's necessary.
const search = api.createSearch({ index: 'test', fullTextFilter: 'Star Trek 2'  });

search()
  .then(...)
  .catch(...);

Thank you for clarification.

mustafa519 avatar Feb 05 '24 16:02 mustafa519