appbaseio / reactivesearch

Search UI components for React and Vue
https://opensource.appbase.io/reactivesearch
Apache License 2.0
4.89k stars 471 forks source link

The msearch request must be terminated by a newline [\n] #2212

Closed jorgeju4rez closed 1 year ago

jorgeju4rez commented 1 year ago

Affected Projects: React

Library Version: 4.0.0-rc.10

Describe the bug

I am migrating from version 3.43.6 to 4.0.0-rc.10 and it is giving me an unusual error

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "The msearch request must be terminated by a newline [\n]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "The msearch request must be terminated by a newline [\n]"
    },
    "status": 400
}

To Reproduce

import React from "react";
import { ReactiveBase, SearchBox } from "@appbaseio/reactivesearch";

function List() {
  return (
    <ReactiveBase
      url="https://my-elastic.com"
      app="products"
      credentials="aaa:bbb"
      transformRequest={(props) => ({
        ...props,
        url: props.url.replace("_reactivesearch", "_msearch")
      })}
    >
      <SearchBox
        componentId="searchbox"
        dataField={[
          {
            field: "products.code.keyword",
            weight: 20
          }
        ]}
        placeholder="Search for books or authors"
      />
    </ReactiveBase>
  );
}

export default List;
siddharthlatest commented 1 year ago

@jorgeju4rez While you're replacing the _reactivesearch part in the URL, the body is still for the ReactiveSearch API. Basically, starting v4, it's required for you to use the ReactiveSearch API service (cloud or self-hosted) to connect to Elasticsearch instead of making a direct _msearch call.

See the discussion here for context: https://github.com/appbaseio/reactivesearch/discussions/2197