ElasticSearch OSEM

Object/Search Engine Mapping for ElasticSearch

License

License

Categories

Categories

Search Business Logic Libraries Elasticsearch
GroupId

GroupId

com.github.kzwang
ArtifactId

ArtifactId

elasticsearch-osem
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

ElasticSearch OSEM
Object/Search Engine Mapping for ElasticSearch
Project URL

Project URL

http://github.com/kzwang/elasticsearch-osem
Source Code Management

Source Code Management

http://github.com/kzwang/elasticsearch-osem

Download elasticsearch-osem

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.kzwang/elasticsearch-osem/ -->
<dependency>
    <groupId>com.github.kzwang</groupId>
    <artifactId>elasticsearch-osem</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.kzwang/elasticsearch-osem/
implementation 'com.github.kzwang:elasticsearch-osem:2.0.0'
// https://jarcasting.com/artifacts/com.github.kzwang/elasticsearch-osem/
implementation ("com.github.kzwang:elasticsearch-osem:2.0.0")
'com.github.kzwang:elasticsearch-osem:jar:2.0.0'
<dependency org="com.github.kzwang" name="elasticsearch-osem" rev="2.0.0">
  <artifact name="elasticsearch-osem" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.kzwang', module='elasticsearch-osem', version='2.0.0')
)
libraryDependencies += "com.github.kzwang" % "elasticsearch-osem" % "2.0.0"
[com.github.kzwang/elasticsearch-osem "2.0.0"]

Dependencies

compile (6)

Group / Artifact Type Version
org.elasticsearch : elasticsearch jar 1.0.0
com.fasterxml.jackson.core : jackson-core jar 2.3.1
com.fasterxml.jackson.core : jackson-annotations jar 2.3.1
com.fasterxml.jackson.core : jackson-databind jar 2.3.1
com.google.guava : guava jar 16.0
org.reflections : reflections jar 0.9.9-RC1

runtime (1)

Group / Artifact Type Version
log4j : log4j jar 1.2.17

test (4)

Group / Artifact Type Version
org.elasticsearch : elasticsearch test-jar 1.0.0
org.hamcrest : hamcrest-all jar 1.3
com.carrotsearch.randomizedtesting : randomizedtesting-runner jar 2.0.15
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

ElasticSearch OSEM

Object Search Engine Mapping for ElasticSearch

Build Status

OSEM elasticsearch Release date
2.1.0-SNAPSHOT (master) 1.0.0
2.0.0 1.0.0 2014-02-13
2.0.0.RC1 1.0.0.RC2 2014-02-06
1.1.0-SNAPSHOT (1.x) 0.90.10
1.0.0 0.90.10 2014-02-03

Example

Please see ElasticSearchOsemIntegrationTest.java for more examples

Create model:

    @Indexable(name = "tweetIndex", numericDetection = NumericDetectionEnum.TRUE, allFieldEnabled = false,
            sizeFieldEnabled = true, timestampFieldEnabled = true, timestampFieldPath = "tweetDatetime",
            timestampFieldFormat = "yyyy/MM/dd HH:mm:ss")
    public class Tweet {

        @IndexableId(index = IndexEnum.NOT_ANALYZED)
        @IndexableProperty
        private Long id;

        @IndexableComponent
        private User user;

        @IndexableProperty(store = true, coerce = false, copyTo = {"image"}, fieldDataLoading = FieldDataLoading.EAGER,
                            fieldDataFormat = FieldDataFormat.FST, fieldDataFilterRegexPattern = "*", fieldDataFilterFrequencyMin = "0.001",
                            fieldDataFilterFrequencyMax = "0.1", fieldDataFilterFrequencyMinSegmentSize = "500")
        private String tweetString;

        @IndexableProperty(format = "basic_date||yyyy/MM/dd")
        private Date tweetDate;

        @IndexableProperty(serializer = ImageSerializer.class, jsonInclude = JsonInclude.ALWAYS, docValuesFormat = DocValuesFormatEnum.DISK)
        private String image;

        @IndexableProperty(analyzer = "standard")
        private List<String> urls;

        @IndexableComponent(name = "mentionedUsers")
        private List<User> mentionedUserList;

        @IndexableProperty
        private Boolean flagged;

        @IndexableProperty(format = "basic_date_time_no_millis")
        private List<Date> specialDates;

        @IndexableProperty(name = "tweetDatetime", format = "yyyy/MM/dd HH:mm:ss")
        public Date getTweetDatetime() {
            return tweetDate;
        }
    }

Create Mapping:

    Client client = nodeBuilder().node().client();
    ElasticSearchIndexer indexer = new ElasticSearchIndexer(client, indexName);
    indexer.createMapping(Tweet.class);

Index Object:

    Tweet tweet = new Tweet();
    ...
    indexer.index(tweet);

Delete Object:

    Tweet tweet = ...;
    indexer.delete(tweet);

Get Object from index:

    ElasticSearchSearcher searcher = new ElasticSearchSearcherImpl(client, indexName);
    Tweet tweet = searcher.getById(Tweet.class, tweet.getId().toString());

Search Object:

    List<Tweet> searchResult = searcher.search(Tweet.class, QueryBuilders.matchAllQuery(), null);

Maven

    <dependency>
        <groupId>com.github.kzwang</groupId>
        <artifactId>elasticsearch-osem</artifactId>
        <version>2.0.0</version>
    </dependency>

Versions

Version
2.0.0
2.0.0.RC1
1.0.0