Coder Social home page Coder Social logo

meilisearch-rest-client's Introduction

Meilisearch Rest Client

License Maven CI Codecov


Meilisearch is a lightning-fast search engine that fits effortlessly into your apps, websites, and workflow.

The goal of this library is to provide a object-oriented, semantic, reactive, and streamlined meilisearch-rest-client, supporting reactivity through reactor-netty-http.

Version

The version number of this library is named by appending .X to the version number in the official documentation.

Doc's Version Library's Version
V1.8(latest) 1.8.X.X
V1.7 1.7.X.X
V1.6 1.6.X.X
V1.5 1.5.X.X

Dependencies

By default, this library depends on libraries as fallows:

  • reactor-netty-http(required)
  • jackson(replaceable by providing implementation of io.github.honhimw.ms.JsonHandler)

Installation

# build from sources
$ ./gradlew clean build -x test
# publish to maven local
$ ./gradlew publishToMavenLocal
// Gradle
implementation 'io.github.honhimw:meilisearch-rest-client:1.7.0.3'
<!-- Maven -->
<dependency>
    <groupId>io.github.honhimw</groupId>
    <artifactId>meilisearch-rest-client</artifactId>
    <version>1.7.0.3</version>
</dependency>

Copy Snippets here.

Usage

Reactive(reactor)

public static void main(String[] args) {
    JsonHandler jsonHandler = new JacksonJsonHandler();
    @Cleanup
    ReactiveMSearchClient client = ReactiveMSearchClient.create(builder -> builder
        .enableSSL(false)                    // true: https, false: http
        .host("{{meilisearch-server-host}}") // server host
        .port(7700)                          // server port
        .jsonHandler(jsonHandler)
        .httpClient(ReactiveHttpUtils.getInstance(http -> http.readTimeout(Duration.ofMillis(100)))));
    String indexUid = "movies";
    Mono<SearchResponse<Movie>> searchResponse = client.indexes(indexes -> indexes
        .search(indexUid, search -> search
            .find("hello world", Movie.class)));
    List<Movie> hits = searchResponse.block().getHits();
    // or
    List<Movie> hits2 = client.indexes(indexes -> indexes
        .search(indexUid, Movie.class, search -> search
            .find(q -> q
                .q("hello world")
                .limit(1)
            )
            .map(SearchResponse::getHits)
        )
    ).block();
}

Blocking

public static void main(String[] args) {
    JsonHandler jsonHandler = new JacksonJsonHandler();
    @Cleanup
    MSearchClient client = MSearchClient.create(builder -> builder
        .enableSSL(false)                    // true: https, false: http
        .host("{{meilisearch-server-host}}") // server host
        .port(7700)                          // server port
        .jsonHandler(jsonHandler)
        .httpClient(ReactiveHttpUtils.getInstance(http -> http.readTimeout(Duration.ofMillis(100)))));
    String indexUid = "movies";
    SearchResponse<Movie> searchResponse = client.indexes(indexes -> indexes
        .search(indexUid, search -> search
            .find("hello world", Movie.class)));
    List<Movie> hits = searchResponse.getHits();
    // or
    List<Movie> hits2 = client.indexes(indexes -> indexes
        .search(indexUid, Movie.class, search -> search
            .find(q -> q
                .q("hello world")
                .limit(1)
            )
            .getHits()
        )
    );
}

Run Tests

$ ./gradlew test

Create file named profile-test.properties under project root directory.

./meilisearch-rest-client
└── profile-test.properties
meili-search.host=127.0.0.1
meili-search.port=7700
meili-search.api-key=MASTER_KEY

Note: You may also set profiles.active in gradle.properties for loading different properties file such as:

profile-alpha.properties: by setting profiles.active=alpha
profile-beta.properties: by setting profiles.active=beta

meilisearch-rest-client's People

Contributors

dependabot[bot] avatar honhimw avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.