Skip to content

Samples to demonstrate features of picturesafe-search, an open source library implementing an opinionated, fresh approach to implement new search/analytics enabled applications or enhance legacy software based on relational databases with powerful full text search capabilities.

License

Notifications You must be signed in to change notification settings

picturesafe/picturesafe-search-samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

picturesafe-search samples

Samples for the picturesafe-search library.

Installation

The picturesafe-search samples require a running Elasticsearch server from version 7.x.

  • Download and unpack the Elasticsearch official distribution.

  • Run bin/elasticsearch on Linux or macOS. Run bin\elasticsearch.bat on Windows.

Run samples

Clone Maven project and run samples from IDE or command line.

Run "GettingStarted" sample
mvn exec:java -Dexec.mainClass="de.picturesafe.search.samples.gettingstarted.GettingStarted"

Sample output

The output is logged out on the console (see log4j2.xml), for example:

console output1

By default, the internally generated Elasticsearch request (and response) is also logged out, so that it can be examined how Elasticsearch executes the expression-based Java search:

console output2

The following Java search leads to the Elasticsearch request below:

Expression-based Java search
Expression expression = OperationExpression.and(
    new FulltextExpression("test title"),
    new ValueExpression("count", ValueExpression.Comparison.GE, 102));

SearchResult searchResult = singleIndexElasticsearchService.search(expression, SearchParameter.DEFAULT);
Internally generated Elasticsearch request
{
	"from": 0,
	"size": 100,
	"query": {
		"bool": {
			"must": [{
				"bool": {
					"filter": [{
						"query_string": {
							"query": "(test && title)",
							"fields": ["fulltext^1.0"],
							"type": "best_fields",
							"default_operator": "and",
							"max_determinized_states": 10000,
							"enable_position_increments": true,
							"fuzziness": "AUTO",
							"fuzzy_prefix_length": 0,
							"fuzzy_max_expansions": 50,
							"phrase_slop": 0,
							"analyze_wildcard": false,
							"escape": false,
							"auto_generate_synonyms_phrase_query": true,
							"fuzzy_transpositions": true,
							"boost": 1.0
						}
					}],
					"adjust_pure_negative": true,
					"boost": 1.0
				}
			}],
			"filter": [{
				"range": {
					"count": {
						"from": 102,
						"to": null,
						"include_lower": true,
						"include_upper": true,
						"boost": 1.0
					}
				}
			}],
			"adjust_pure_negative": true,
			"boost": 1.0
		}
	}
}

About

Samples to demonstrate features of picturesafe-search, an open source library implementing an opinionated, fresh approach to implement new search/analytics enabled applications or enhance legacy software based on relational databases with powerful full text search capabilities.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages