Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Searching API improvements #7

Closed
gorbunkov opened this issue Apr 1, 2021 · 0 comments
Closed

Searching API improvements #7

gorbunkov opened this issue Apr 1, 2021 · 0 comments
Assignees
Milestone

Comments

@gorbunkov
Copy link
Contributor

gorbunkov commented Apr 1, 2021

Option 1

We may implement an approach similar to Jmix FileStorage.

public interface Searcher { 
   String getName();

   SearchResult search(String query);
   SearchResult search(String query, SearchContext context); // move query into context?
}

public interface SearcherLocator {
   Searcher getByName(String name);
   Searcher getDefault();
}

public class SearchContext {
    long size;
    long offset;
    String query;
}

There may be multiple Searcher implementations - each uses its own search strategy: term search, search by query, etc. Each searcher has a name. SearcherLocator locates searchers by name. One of the searchers is a default searcher (defined by configuration property).

There must be a way to define which indexes (for what entities) we want to search.

A searcher name may be defined for a searchField component:

<search:searchField id="sf1" searcher="term"/>

Option 2

There will be a single Searcher implementation. There may be multiple SearchStrategy instances

public interface Searcher { 
   SearchResult search(String query);
   SearchResult search(SearchContext context);
   SearchResult search(SearchContext context, SearchStrategy searchStrategy);
}

public class SearchContext {
    long size;
    long offset;
    String query;
}

public interface SearchStrategy {
    String getName();
    SearchRequest buildSearchRequest(SearchContext searchContext);   
}

public interface SearchStrategyLocator {
   Searcher getByName(String name);
   Searcher getDefault();
}

Misc

Also consider implementing an API for transforming SearchResult (it contains a list of SearchResultEntry, each entry stores a collection of FieldHit) into a collection of entities.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants