POM for ElasticSearch 0.17.2

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

POM for ElasticSearch 0.17.2

jabawaba-2
Hi,

I'm new to ElasticSearch and Lucene (2 weeks) and especially to maven
(yesterday). I am writing java proof of concept to learn how to use
ES. I was successful in writing Apache Http Client and Jersey clients
to communicate with ES. The two clients were developed in maven. Now,
I am trying to replicate the effort using the native ES java client
but I am having trouble downloading the ES jars so I can use them to
build my ES java client.

My POM (shown at the end) is having trouble parsing:
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>0.17.2</version>
            <!--<version>0.16.0</version>-->
        </dependency>

As you can see, I tried both 0.16.0 and 0.17.2 to no avail. Can you
please help/show me how to update my pom in order to get the client to
build on maven.

On a related note, the primary aim of this POC is to figure out how to
access the ES POJOs for both the request and response. In other words,
so far, I have been exchanging JSONs between Jersey and ES.
Consequently, I had to write my own java POJO, and using jackson, to
convert the returned JSON (from ES rest api) to POJO. I found that to
be cumbersome.
Given the following JSON, my guess is that there should be a mapped
POJO in the public ES API
{
    "query": {
        "filtered" : {
            "query" : {
                "query_string" : {
                    "query" : "some query string here"
                }
            },
            "filter" : {
                "term" : { "user" : "kimchy" }
            }
        }
    }
}
And conversely, the result set JSON should have it's own public POJO.
Without these public POJOs, I will have to write dozens of POJOs to
represent the various request and response JSONS.

I my guess correct? If so, can you provide me with the package path.

Thank you for taking the time to help me with these two problems.

============================================================

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <repositories>
        <!-- Start Jersey Repositories. -->
        <repository>
            <id>maven2-repository.java.net</id>
            <name>Java.net Repository for Maven</name>
            <url>http://download.java.net/maven/2/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>maven-repository.java.net</id>
            <name>Java.net Maven 1 Repository (legacy)</name>
            <url>http://download.java.net/maven/1</url>
            <layout>legacy</layout>
        </repository>
        <!-- End Jersey Repositories. -->
        <!-- Start ElasticSearch Repositories. -->
        <repository>
            <id>oss.sonatype.org</id>
            <name>OSS Sonatype</name>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <url>https://oss.sonatype.org/content/repositories/
releases/</url>
        </repository>
        <repository>
            <id>sonatype-snapshots</id>
            <name>Sonatype Snapshots Repository</name>
            <url>http://oss.sonatype.org/content/repositories/
snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <!-- Start ElasticSearch Repositories. -->
    </repositories>
    <groupId>com.example.es</groupId>
    <artifactId>es</artifactId>
    <!--<packaging>jar</packaging>-->
    <version>1.0-SNAPSHOT</version>
    <name>es</name>
    <url>http://maven.apache.org</url>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2.1</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</
descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
 
<mainClass>com.example.es.apachehttpclient.Delete</mainClass>
 
<mainClass>com.example.es.apachehttpclient.Index</mainClass>
 
<mainClass>com.example.es.apachehttpclient.Search</mainClass>
                            <mainClass>com.example.es.jersey.Search</
mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <!-- Start ElasticSearch Dependencies -->
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>0.16.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-core</artifactId>
            <version>3.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-analyzers</artifactId>
            <version>3.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-snowball</artifactId>
            <version>3.0.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-fast-vector-highlighter</artifactId>
            <version>3.0.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-highlighter</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-queries</artifactId>
            <version>2.4.0</version>
        </dependency>
        <!-- End ElasticSearch Dependencies -->
        <!-- Start Jersey Dependencies -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.8</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-apache-client</artifactId>
            <version>1.8</version>
        </dependency>
        <!-- End Jersey Dependencies -->
        <!-- Start Apache Http Client Dependencies -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.1.1</version>
        </dependency>
        <!-- End Apache Http Client Dependencies -->
        <!-- Start JUNIT Dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.2</version>
            <scope>test</scope>
        </dependency>
        <!-- End JUNIT Dependencies -->
    </dependencies>
</project>

Reply | Threaded
Open this post in threaded view
|

Re: POM for ElasticSearch 0.17.2

Ivan Brusic
Your maven settings look correct, although I am not sure the newlines are caused by your email editor or not:

...
           <url>https://oss.sonatype.org/content/repositories/
releases/</url>
...
           <url>http://oss.sonatype.org/content/repositories/
snapshots/</url>
...

Are the newlines after .../repositories/ in the original source? If so, those are the culprits.

You can see the POMs here:

As far as POJOs go, you do have the org.elasticsearch.action.ActionRequest and org.elasticsearch.action.ActionResponse class hierarchies, however instances are are probably better created using static factories and builders and not via a simple constructor. 

The actual hits in a SearchResponse are of type org.elasticsearch.search.SearchHit

BTW, it would be great to have the API online instead of having to point to source code in github.

-- 
Ivan

On Tue, Aug 2, 2011 at 8:05 PM, jabawaba <[hidden email]> wrote:
Hi,

I'm new to ElasticSearch and Lucene (2 weeks) and especially to maven
(yesterday). I am writing java proof of concept to learn how to use
ES. I was successful in writing Apache Http Client and Jersey clients
to communicate with ES. The two clients were developed in maven. Now,
I am trying to replicate the effort using the native ES java client
but I am having trouble downloading the ES jars so I can use them to
build my ES java client.

My POM (shown at the end) is having trouble parsing:
       <dependency>
           <groupId>org.elasticsearch</groupId>
           <artifactId>elasticsearch</artifactId>
           <version>0.17.2</version>
           <!--<version>0.16.0</version>-->
       </dependency>

As you can see, I tried both 0.16.0 and 0.17.2 to no avail. Can you
please help/show me how to update my pom in order to get the client to
build on maven.

On a related note, the primary aim of this POC is to figure out how to
access the ES POJOs for both the request and response. In other words,
so far, I have been exchanging JSONs between Jersey and ES.
Consequently, I had to write my own java POJO, and using jackson, to
convert the returned JSON (from ES rest api) to POJO. I found that to
be cumbersome.
Given the following JSON, my guess is that there should be a mapped
POJO in the public ES API
{
   "query": {
       "filtered" : {
           "query" : {
               "query_string" : {
                   "query" : "some query string here"
               }
           },
           "filter" : {
               "term" : { "user" : "kimchy" }
           }
       }
   }
}
And conversely, the result set JSON should have it's own public POJO.
Without these public POJOs, I will have to write dozens of POJOs to
represent the various request and response JSONS.

I my guess correct? If so, can you provide me with the package path.

Thank you for taking the time to help me with these two problems.

============================================================

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <repositories>
       <!-- Start Jersey Repositories. -->
       <repository>
           <id>maven2-repository.java.net</id>
           <name>Java.net Repository for Maven</name>
           <url>http://download.java.net/maven/2/</url>
           <layout>default</layout>
       </repository>
       <repository>
           <id>maven-repository.java.net</id>
           <name>Java.net Maven 1 Repository (legacy)</name>
           <url>http://download.java.net/maven/1</url>
           <layout>legacy</layout>
       </repository>
       <!-- End Jersey Repositories. -->
       <!-- Start ElasticSearch Repositories. -->
       <repository>
           <id>oss.sonatype.org</id>
           <name>OSS Sonatype</name>
           <releases>
               <enabled>true</enabled>
           </releases>
           <snapshots>
               <enabled>false</enabled>
           </snapshots>
           <url>https://oss.sonatype.org/content/repositories/
releases/</url>
       </repository>
       <repository>
           <id>sonatype-snapshots</id>
           <name>Sonatype Snapshots Repository</name>
           <url>http://oss.sonatype.org/content/repositories/
snapshots/</url>
           <snapshots>
               <enabled>true</enabled>
           </snapshots>
       </repository>
       <!-- Start ElasticSearch Repositories. -->
   </repositories>
   <groupId>com.example.es</groupId>
   <artifactId>es</artifactId>
   <!--<packaging>jar</packaging>-->
   <version>1.0-SNAPSHOT</version>
   <name>es</name>
   <url>http://maven.apache.org</url>
   <build>
       <plugins>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <version>2.3.2</version>
               <configuration>
                   <source>1.6</source>
                   <target>1.6</target>
               </configuration>
           </plugin>

           <plugin>
               <artifactId>maven-assembly-plugin</artifactId>
               <version>2.2.1</version>
               <configuration>
                   <descriptorRefs>
                       <descriptorRef>jar-with-dependencies</
descriptorRef>
                   </descriptorRefs>
                   <archive>
                       <manifest>

<mainClass>com.example.es.apachehttpclient.Delete</mainClass>

<mainClass>com.example.es.apachehttpclient.Index</mainClass>

<mainClass>com.example.es.apachehttpclient.Search</mainClass>
                           <mainClass>com.example.es.jersey.Search</
mainClass>
                       </manifest>
                   </archive>
               </configuration>
           </plugin>
       </plugins>
   </build>

   <dependencies>
       <!-- Start ElasticSearch Dependencies -->
       <dependency>
           <groupId>org.elasticsearch</groupId>
           <artifactId>elasticsearch</artifactId>
           <version>0.16.0</version>
       </dependency>
       <dependency>
           <groupId>org.apache.lucene</groupId>
           <artifactId>lucene-core</artifactId>
           <version>3.3.0</version>
       </dependency>
       <dependency>
           <groupId>org.apache.lucene</groupId>
           <artifactId>lucene-analyzers</artifactId>
           <version>3.3.0</version>
       </dependency>
       <dependency>
           <groupId>org.apache.lucene</groupId>
           <artifactId>lucene-snowball</artifactId>
           <version>3.0.3</version>
       </dependency>
       <dependency>
           <groupId>org.apache.lucene</groupId>
           <artifactId>lucene-fast-vector-highlighter</artifactId>
           <version>3.0.3</version>
       </dependency>
       <dependency>
           <groupId>org.apache.lucene</groupId>
           <artifactId>lucene-highlighter</artifactId>
           <version>2.4.0</version>
       </dependency>
       <dependency>
           <groupId>org.apache.lucene</groupId>
           <artifactId>lucene-queries</artifactId>
           <version>2.4.0</version>
       </dependency>
       <!-- End ElasticSearch Dependencies -->
       <!-- Start Jersey Dependencies -->
       <dependency>
           <groupId>com.sun.jersey</groupId>
           <artifactId>jersey-client</artifactId>
           <version>1.8</version>
       </dependency>
       <dependency>
           <groupId>com.sun.jersey.contribs</groupId>
           <artifactId>jersey-apache-client</artifactId>
           <version>1.8</version>
       </dependency>
       <!-- End Jersey Dependencies -->
       <!-- Start Apache Http Client Dependencies -->
       <dependency>
           <groupId>org.apache.httpcomponents</groupId>
           <artifactId>httpclient</artifactId>
           <version>4.1.1</version>
       </dependency>
       <!-- End Apache Http Client Dependencies -->
       <!-- Start JUNIT Dependencies -->
       <dependency>
           <groupId>junit</groupId>
           <artifactId>junit</artifactId>
           <version>3.8.2</version>
           <scope>test</scope>
       </dependency>
       <!-- End JUNIT Dependencies -->
   </dependencies>
</project>


Reply | Threaded
Open this post in threaded view
|

Re: POM for ElasticSearch 0.17.2

jabawaba-2
Hi Ivan,

Thank you for your reply.

1. You are correct, my POM doesn't have newlines. I don't know how the
got inserted. I noticed there was a slash at the end (after releases
and snapshots). I removed them but made no difference.

    <repositories>
        <repository>
            <id>maven2-repository.java.net</id>
            <name>Java.net Repository for Maven</name>
            <url>http://download.java.net/maven/2/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>maven-repository.java.net</id>
            <name>Java.net Maven 1 Repository (legacy)</name>
            <url>http://download.java.net/maven/1</url>
            <layout>legacy</layout>
        </repository>
        <!-- Start ElasticSearch Repositories. -->
        <repository>
            <id>oss.sonatype.org</id>
            <name>OSS Sonatype</name>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <url>https://oss.sonatype.org/content/repositories/
releases</url>
        </repository>
        <repository>
            <id>sonatype-snapshots</id>
            <name>Sonatype Snapshots Repository</name>
            <url>http://oss.sonatype.org/content/repositories/
snapshots</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <!-- Start ElasticSearch Repositories. -->
    </repositories>

2. Here is my very primitive java client. I'm just trying to test
whether maven can pick up the ES jars. Apparently it can't.

package com.example.es.es;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;

public class Search {

  public static void main(String[] args) {

    // on startup

    Client client = null;

    try {
      client = new TransportClient()
              .addTransportAddress(new
InetSocketTransportAddress("localhost", 9300))
              .addTransportAddress(new
InetSocketTransportAddress("localhost", 9300));
      // my stuff goes here.
    } finally {
      // on shutdown
      client.close();
    }
  }
}

3. And here is the output from mvn compile (I use mvn
assembly:assembly in order to construct the entire jar w/o
dependencies, but initially, I want to get compile to work). I noticed
on repos uses https another uses http. I tried all four combinations
of http and https to no avail.

$ mvn compile
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building es
[INFO]    task-segment: [compile]
[INFO]
------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/admin/dev/
elasticsearch/examples/java/maven/es/src/main/resources
Downloading: http://download.java.net/maven/2//org/elasticsearch/elasticsearch/0.17.2/elasticsearch-0.17.2.pom
[INFO] Unable to find resource 'org.elasticsearch:elasticsearch:pom:
0.17.2' in repository maven2-repository.java.net (http://
download.java.net/maven/2/)
Downloading: http://download.java.net/maven/1/org.elasticsearch/poms/elasticsearch-0.17.2.pom
[INFO] Unable to find resource 'org.elasticsearch:elasticsearch:pom:
0.17.2' in repository maven-repository.java.net (http://
download.java.net/maven/1)
Downloading:
https://oss.sonatype.org/content/repositories/releases/org/elasticsearch/elasticsearch/0.17.2/elasticsearch-0.17.2.pom
[WARNING] Unable to get resource 'org.elasticsearch:elasticsearch:pom:
0.17.2' from repository oss.sonatype.org (https://oss.sonatype.org/
content/repositories/releases): Error transferring file: Operation
timed out
Downloading:
http://oss.sonatype.org/content/repositories/snapshots/org/elasticsearch/elasticsearch/0.17.2/elasticsearch-0.17.2.pom
[WARNING] Unable to get resource 'org.elasticsearch:elasticsearch:pom:
0.17.2' from repository sonatype-snapshots (http://oss.sonatype.org/
content/repositories/snapshots): Error transferring file: Operation
timed out
Downloading: http://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/0.17.2/elasticsearch-0.17.2.pom
[INFO] Unable to find resource 'org.elasticsearch:elasticsearch:pom:
0.17.2' in repository central (http://repo1.maven.org/maven2)
Downloading: http://download.java.net/maven/2//org/elasticsearch/elasticsearch/0.17.2/elasticsearch-0.17.2.jar
[INFO] Unable to find resource 'org.elasticsearch:elasticsearch:jar:
0.17.2' in repository maven2-repository.java.net (http://
download.java.net/maven/2/)
Downloading: http://download.java.net/maven/1/org.elasticsearch/jars/elasticsearch-0.17.2.jar
[INFO] Unable to find resource 'org.elasticsearch:elasticsearch:jar:
0.17.2' in repository maven-repository.java.net (http://
download.java.net/maven/1)
Downloading:
https://oss.sonatype.org/content/repositories/releases/org/elasticsearch/elasticsearch/0.17.2/elasticsearch-0.17.2.jar
[WARNING] Unable to get resource 'org.elasticsearch:elasticsearch:jar:
0.17.2' from repository oss.sonatype.org (https://oss.sonatype.org/
content/repositories/releases): Error transferring file: Operation
timed out
Downloading:
http://oss.sonatype.org/content/repositories/snapshots/org/elasticsearch/elasticsearch/0.17.2/elasticsearch-0.17.2.jar
[WARNING] Unable to get resource 'org.elasticsearch:elasticsearch:jar:
0.17.2' from repository sonatype-snapshots (http://oss.sonatype.org/
content/repositories/snapshots): Error transferring file: Operation
timed out
Downloading: http://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/0.17.2/elasticsearch-0.17.2.jar
[INFO] Unable to find resource 'org.elasticsearch:elasticsearch:jar:
0.17.2' in repository central (http://repo1.maven.org/maven2)
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Failed to resolve artifact.


Any help is greatly appreciated.
Thank you


On Aug 2, 8:32 pm, Ivan Brusic <[hidden email]> wrote:

> Your maven settings look correct, although I am not sure the newlines are
> caused by your email editor or not:
>
> ...
>            <url>https://oss.sonatype.org/content/repositories/
> releases/</url>
> ...
>            <url>http://oss.sonatype.org/content/repositories/
> snapshots/</url>
> ...
>
> Are the newlines after .../repositories/ in the original source? If so,
> those are the culprits.
>
> You can see the POMs here:https://oss.sonatype.org/content/repositories/releases/org/elasticsea...
>
> As far as POJOs go, you do have the org.elasticsearch.action.ActionRequest
> and org.elasticsearch.action.ActionResponse class hierarchies, however
> instances are are probably better created using static factories and
> builders and not via a simple constructor.
>
> The actual hits in a SearchResponse are of
> type org.elasticsearch.search.SearchHit
>
> BTW, it would be great to have the API online instead of having to point to
> source code in github.
>
> --
> Ivan
>
> On Tue, Aug 2, 2011 at 8:05 PM, jabawaba <[hidden email]> wrote:
> > Hi,
>
> > I'm new to ElasticSearch and Lucene (2 weeks) and especially to maven
> > (yesterday). I am writing java proof of concept to learn how to use
> > ES. I was successful in writing Apache Http Client and Jersey clients
> > to communicate with ES. The two clients were developed in maven. Now,
> > I am trying to replicate the effort using the native ES java client
> > but I am having trouble downloading the ES jars so I can use them to
> > build my ES java client.
>
> > My POM (shown at the end) is having trouble parsing:
> >        <dependency>
> >            <groupId>org.elasticsearch</groupId>
> >            <artifactId>elasticsearch</artifactId>
> >            <version>0.17.2</version>
> >            <!--<version>0.16.0</version>-->
> >        </dependency>
>
> > As you can see, I tried both 0.16.0 and 0.17.2 to no avail. Can you
> > please help/show me how to update my pom in order to get the client to
> > build on maven.
>
> > On a related note, the primary aim of this POC is to figure out how to
> > access the ES POJOs for both the request and response. In other words,
> > so far, I have been exchanging JSONs between Jersey and ES.
> > Consequently, I had to write my own java POJO, and using jackson, to
> > convert the returned JSON (from ES rest api) to POJO. I found that to
> > be cumbersome.
> > Given the following JSON, my guess is that there should be a mapped
> > POJO in the public ES API
> > {
> >    "query": {
> >        "filtered" : {
> >            "query" : {
> >                "query_string" : {
> >                    "query" : "some query string here"
> >                }
> >            },
> >            "filter" : {
> >                "term" : { "user" : "kimchy" }
> >            }
> >        }
> >    }
> > }
> > And conversely, the result set JSON should have it's own public POJO.
> > Without these public POJOs, I will have to write dozens of POJOs to
> > represent the various request and response JSONS.
>
> > I my guess correct? If so, can you provide me with the package path.
>
> > Thank you for taking the time to help me with these two problems.
>
> > ============================================================
>
> > <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://
> >www.w3.org/2001/XMLSchema-instance"
> >         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> >http://maven.apache.org/maven-v4_0_0.xsd">
> >    <modelVersion>4.0.0</modelVersion>
> >    <repositories>
> >        <!-- Start Jersey Repositories. -->
> >        <repository>
> >            <id>maven2-repository.java.net</id>
> >            <name>Java.net Repository for Maven</name>
> >            <url>http://download.java.net/maven/2/</url>
> >            <layout>default</layout>
> >        </repository>
> >        <repository>
> >            <id>maven-repository.java.net</id>
> >            <name>Java.net Maven 1 Repository (legacy)</name>
> >            <url>http://download.java.net/maven/1</url>
> >            <layout>legacy</layout>
> >        </repository>
> >        <!-- End Jersey Repositories. -->
> >        <!-- Start ElasticSearch Repositories. -->
> >        <repository>
> >            <id>oss.sonatype.org</id>
> >            <name>OSS Sonatype</name>
> >            <releases>
> >                <enabled>true</enabled>
> >            </releases>
> >            <snapshots>
> >                <enabled>false</enabled>
> >            </snapshots>
> >            <url>https://oss.sonatype.org/content/repositories/
> > releases/</url>
> >        </repository>
> >        <repository>
> >            <id>sonatype-snapshots</id>
> >            <name>Sonatype Snapshots Repository</name>
> >            <url>http://oss.sonatype.org/content/repositories/
> > snapshots/</url>
> >            <snapshots>
> >                <enabled>true</enabled>
> >            </snapshots>
> >        </repository>
> >        <!-- Start ElasticSearch Repositories. -->
> >    </repositories>
> >    <groupId>com.example.es</groupId>
> >    <artifactId>es</artifactId>
> >    <!--<packaging>jar</packaging>-->
> >    <version>1.0-SNAPSHOT</version>
> >    <name>es</name>
> >    <url>http://maven.apache.org</url>
> >    <build>
> >        <plugins>
> >            <plugin>
> >                <groupId>org.apache.maven.plugins</groupId>
> >                <artifactId>maven-compiler-plugin</artifactId>
> >                <version>2.3.2</version>
> >                <configuration>
> >                    <source>1.6</source>
> >                    <target>1.6</target>
> >                </configuration>
> >            </plugin>
>
> >            <plugin>
> >                <artifactId>maven-assembly-plugin</artifactId>
> >                <version>2.2.1</version>
> >                <configuration>
> >                    <descriptorRefs>
> >                        <descriptorRef>jar-with-dependencies</
> > descriptorRef>
> >                    </descriptorRefs>
> >                    <archive>
> >                        <manifest>
>
> > <mainClass>com.example.es.apachehttpclient.Delete</mainClass>
>
> > <mainClass>com.example.es.apachehttpclient.Index</mainClass>
>
> > <mainClass>com.example.es.apachehttpclient.Search</mainClass>
> >                            <mainClass>com.example.es.jersey.Search</
> > mainClass>
> >                        </manifest>
> >                    </archive>
> >                </configuration>
> >            </plugin>
> >        </plugins>
> >    </build>
>
> >    <dependencies>
> >        <!-- Start ElasticSearch Dependencies -->
> >        <dependency>
> >            <groupId>org.elasticsearch</groupId>
> >            <artifactId>elasticsearch</artifactId>
> >            <version>0.16.0</version>
> >        </dependency>
> >        <dependency>
> >            <groupId>org.apache.lucene</groupId>
> >            <artifactId>lucene-core</artifactId>
> >            <version>3.3.0</version>
> >        </dependency>
> >        <dependency>
> >            <groupId>org.apache.lucene</groupId>
> >            <artifactId>lucene-analyzers</artifactId>
> >            <version>3.3.0</version>
> >        </dependency>
> >        <dependency>
> >            <groupId>org.apache.lucene</groupId>
> >            <artifactId>lucene-snowball</artifactId>
> >            <version>3.0.3</version>
> >        </dependency>
> >        <dependency>
> >            <groupId>org.apache.lucene</groupId>
> >            <artifactId>lucene-fast-vector-highlighter</artifactId>
> >            <version>3.0.3</version>
> >        </dependency>
> >        <dependency>
> >            <groupId>org.apache.lucene</groupId>
> >            <artifactId>lucene-highlighter</artifactId>
> >            <version>2.4.0</version>
> >        </dependency>
> >        <dependency>
> >            <groupId>org.apache.lucene</groupId>
> >            <artifactId>lucene-queries</artifactId>
> >            <version>2.4.0</version>
> >        </dependency>
> >        <!-- End ElasticSearch Dependencies -->
> >        <!-- Start Jersey Dependencies -->
> >        <dependency>
> >            <groupId>com.sun.jersey</groupId>
> >            <artifactId>jersey-client</artifactId>
> >            <version>1.8</version>
> >        </dependency>
> >        <dependency>
> >            <groupId>com.sun.jersey.contribs</groupId>
> >            <artifactId>jersey-apache-client</artifactId>
> >            <version>1.8</version>
> >        </dependency>
> >        <!-- End Jersey Dependencies -->
> >        <!-- Start Apache Http Client Dependencies -->
> >        <dependency>
> >            <groupId>org.apache.httpcomponents</groupId>
> >            <artifactId>httpclient</artifactId>
> >            <version>4.1.1</version>
> >        </dependency>
> >        <!-- End Apache Http Client Dependencies -->
> >        <!-- Start JUNIT Dependencies -->
> >        <dependency>
> >            <groupId>junit</groupId>
> >            <artifactId>junit</artifactId>
> >            <version>3.8.2</version>
> >            <scope>test</scope>
> >        </dependency>
> >        <!-- End JUNIT Dependencies -->
> >    </dependencies>
> > </project>
Reply | Threaded
Open this post in threaded view
|

Re: POM for ElasticSearch 0.17.2

jabawaba-2
Hi Ivan,

After running it twice with absolutely no changes to the POM or source
code, maven was able to download the jar. Very weird. Can not explain
it.

Thank you for your help.
jabawaba

On Aug 2, 11:20 pm, jabawaba <[hidden email]> wrote:

> Hi Ivan,
>
> Thank you for your reply.
>
> 1. You are correct, my POM doesn't have newlines. I don't know how the
> got inserted. I noticed there was a slash at the end (after releases
> and snapshots). I removed them but made no difference.
>
>     <repositories>
>         <repository>
>             <id>maven2-repository.java.net</id>
>             <name>Java.net Repository for Maven</name>
>             <url>http://download.java.net/maven/2/</url>
>             <layout>default</layout>
>         </repository>
>         <repository>
>             <id>maven-repository.java.net</id>
>             <name>Java.net Maven 1 Repository (legacy)</name>
>             <url>http://download.java.net/maven/1</url>
>             <layout>legacy</layout>
>         </repository>
>         <!-- Start ElasticSearch Repositories. -->
>         <repository>
>             <id>oss.sonatype.org</id>
>             <name>OSS Sonatype</name>
>             <releases>
>                 <enabled>true</enabled>
>             </releases>
>             <snapshots>
>                 <enabled>false</enabled>
>             </snapshots>
>             <url>https://oss.sonatype.org/content/repositories/
> releases</url>
>         </repository>
>         <repository>
>             <id>sonatype-snapshots</id>
>             <name>Sonatype Snapshots Repository</name>
>             <url>http://oss.sonatype.org/content/repositories/
> snapshots</url>
>             <snapshots>
>                 <enabled>true</enabled>
>             </snapshots>
>         </repository>
>         <!-- Start ElasticSearch Repositories. -->
>     </repositories>
>
> 2. Here is my very primitive java client. I'm just trying to test
> whether maven can pick up the ES jars. Apparently it can't.
>
> package com.example.es.es;
> import org.elasticsearch.client.Client;
> import org.elasticsearch.client.transport.TransportClient;
> import org.elasticsearch.common.transport.InetSocketTransportAddress;
>
> public class Search {
>
>   public static void main(String[] args) {
>
>     // on startup
>
>     Client client = null;
>
>     try {
>       client = new TransportClient()
>               .addTransportAddress(new
> InetSocketTransportAddress("localhost", 9300))
>               .addTransportAddress(new
> InetSocketTransportAddress("localhost", 9300));
>       // my stuff goes here.
>     } finally {
>       // on shutdown
>       client.close();
>     }
>   }
>
> }
>
> 3. And here is the output from mvn compile (I use mvn
> assembly:assembly in order to construct the entire jar w/o
> dependencies, but initially, I want to get compile to work). I noticed
> on repos uses https another uses http. I tried all four combinations
> of http and https to no avail.
>
> $ mvn compile
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building es
> [INFO]    task-segment: [compile]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] [resources:resources {execution: default-resources}]
> [WARNING] Using platform encoding (MacRoman actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] skip non existing resourceDirectory /Users/admin/dev/
> elasticsearch/examples/java/maven/es/src/main/resources
> Downloading:http://download.java.net/maven/2//org/elasticsearch/elasticsearch/0.1...
> [INFO] Unable to find resource 'org.elasticsearch:elasticsearch:pom:
> 0.17.2' in repository maven2-repository.java.net (http://
> download.java.net/maven/2/)
> Downloading:http://download.java.net/maven/1/org.elasticsearch/poms/elasticsearch...
> [INFO] Unable to find resource 'org.elasticsearch:elasticsearch:pom:
> 0.17.2' in repository maven-repository.java.net (http://
> download.java.net/maven/1)
> Downloading:https://oss.sonatype.org/content/repositories/releases/org/elasticsea...
> [WARNING] Unable to get resource 'org.elasticsearch:elasticsearch:pom:
> 0.17.2' from repository oss.sonatype.org (https://oss.sonatype.org/
> content/repositories/releases): Error transferring file: Operation
> timed out
> Downloading:http://oss.sonatype.org/content/repositories/snapshots/org/elasticsea...
> [WARNING] Unable to get resource 'org.elasticsearch:elasticsearch:pom:
> 0.17.2' from repository sonatype-snapshots (http://oss.sonatype.org/
> content/repositories/snapshots): Error transferring file: Operation
> timed out
> Downloading:http://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/0.17.2/...
> [INFO] Unable to find resource 'org.elasticsearch:elasticsearch:pom:
> 0.17.2' in repository central (http://repo1.maven.org/maven2)
> Downloading:http://download.java.net/maven/2//org/elasticsearch/elasticsearch/0.1...
> [INFO] Unable to find resource 'org.elasticsearch:elasticsearch:jar:
> 0.17.2' in repository maven2-repository.java.net (http://
> download.java.net/maven/2/)
> Downloading:http://download.java.net/maven/1/org.elasticsearch/jars/elasticsearch...
> [INFO] Unable to find resource 'org.elasticsearch:elasticsearch:jar:
> 0.17.2' in repository maven-repository.java.net (http://
> download.java.net/maven/1)
> Downloading:https://oss.sonatype.org/content/repositories/releases/org/elasticsea...
> [WARNING] Unable to get resource 'org.elasticsearch:elasticsearch:jar:
> 0.17.2' from repository oss.sonatype.org (https://oss.sonatype.org/
> content/repositories/releases): Error transferring file: Operation
> timed out
> Downloading:http://oss.sonatype.org/content/repositories/snapshots/org/elasticsea...
> [WARNING] Unable to get resource 'org.elasticsearch:elasticsearch:jar:
> 0.17.2' from repository sonatype-snapshots (http://oss.sonatype.org/
> content/repositories/snapshots): Error transferring file: Operation
> timed out
> Downloading:http://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/0.17.2/...
> [INFO] Unable to find resource 'org.elasticsearch:elasticsearch:jar:
> 0.17.2' in repository central (http://repo1.maven.org/maven2)
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Failed to resolve artifact.
>
> Any help is greatly appreciated.
> Thank you
>
> On Aug 2, 8:32 pm, Ivan Brusic <[hidden email]> wrote:
>
> > Your maven settings look correct, although I am not sure the newlines are
> > caused by your email editor or not:
>
> > ...
> >            <url>https://oss.sonatype.org/content/repositories/
> > releases/</url>
> > ...
> >            <url>http://oss.sonatype.org/content/repositories/
> > snapshots/</url>
> > ...
>
> > Are the newlines after .../repositories/ in the original source? If so,
> > those are the culprits.
>
> > You can see the POMs here:https://oss.sonatype.org/content/repositories/releases/org/elasticsea...
>
> > As far as POJOs go, you do have the org.elasticsearch.action.ActionRequest
> > and org.elasticsearch.action.ActionResponse class hierarchies, however
> > instances are are probably better created using static factories and
> > builders and not via a simple constructor.
>
> > The actual hits in a SearchResponse are of
> > type org.elasticsearch.search.SearchHit
>
> > BTW, it would be great to have the API online instead of having to point to
> > source code in github.
>
> > --
> > Ivan
>
> > On Tue, Aug 2, 2011 at 8:05 PM, jabawaba <[hidden email]> wrote:
> > > Hi,
>
> > > I'm new to ElasticSearch and Lucene (2 weeks) and especially to maven
> > > (yesterday). I am writing java proof of concept to learn how to use
> > > ES. I was successful in writing Apache Http Client and Jersey clients
> > > to communicate with ES. The two clients were developed in maven. Now,
> > > I am trying to replicate the effort using the native ES java client
> > > but I am having trouble downloading the ES jars so I can use them to
> > > build my ES java client.
>
> > > My POM (shown at the end) is having trouble parsing:
> > >        <dependency>
> > >            <groupId>org.elasticsearch</groupId>
> > >            <artifactId>elasticsearch</artifactId>
> > >            <version>0.17.2</version>
> > >            <!--<version>0.16.0</version>-->
> > >        </dependency>
>
> > > As you can see, I tried both 0.16.0 and 0.17.2 to no avail. Can you
> > > please help/show me how to update my pom in order to get the client to
> > > build on maven.
>
> > > On a related note, the primary aim of this POC is to figure out how to
> > > access the ES POJOs for both the request and response. In other words,
> > > so far, I have been exchanging JSONs between Jersey and ES.
> > > Consequently, I had to write my own java POJO, and using jackson, to
> > > convert the returned JSON (from ES rest api) to POJO. I found that to
> > > be cumbersome.
> > > Given the following JSON, my guess is that there should be a mapped
> > > POJO in the public ES API
> > > {
> > >    "query": {
> > >        "filtered" : {
> > >            "query" : {
> > >                "query_string" : {
> > >                    "query" : "some query string here"
> > >                }
> > >            },
> > >            "filter" : {
> > >                "term" : { "user" : "kimchy" }
> > >            }
> > >        }
> > >    }
> > > }
> > > And conversely, the result set JSON should have it's own public POJO.
> > > Without these public POJOs, I will have to write dozens of POJOs to
> > > represent the various request and response JSONS.
>
> > > I my guess correct? If so, can you provide me with the package path.
>
> > > Thank you for taking the time to help me with these two problems.
>
> > > ============================================================
>
> > > <project xmlns="http://maven.apache.org/POM/4.0.0"
>
> ...
>
> read more »
Reply | Threaded
Open this post in threaded view
|

Re: POM for ElasticSearch 0.17.2

dadoonet
In reply to this post by jabawaba-2
I would suggest to try to modify your sonatype repo settings with :

>       <repository>
>           <id>oss.sonatype.org</id>
>           <name>OSS Sonatype</name>
>           <releases>
>               <enabled>true</enabled>
>           </releases>
>           <snapshots>
>               <enabled>false</enabled>
>           </snapshots>
>           <url>http://oss.sonatype.org/content/repositories/
> releases/</url>
>       </repository>


Note the http instead of https.
If you work from your company network, then you can have proxy problems with https ???

I suppose that you have a message like "could not find jar for ..." ? What is your exact error message ?

Hope this helps.
David ;-)

Le 3 août 2011 à 02:05, jabawaba <[hidden email]> a écrit :

> Hi,
>
> I'm new to ElasticSearch and Lucene (2 weeks) and especially to maven
> (yesterday). I am writing java proof of concept to learn how to use
> ES. I was successful in writing Apache Http Client and Jersey clients
> to communicate with ES. The two clients were developed in maven. Now,
> I am trying to replicate the effort using the native ES java client
> but I am having trouble downloading the ES jars so I can use them to
> build my ES java client.
>
> My POM (shown at the end) is having trouble parsing:
>       <dependency>
>           <groupId>org.elasticsearch</groupId>
>           <artifactId>elasticsearch</artifactId>
>           <version>0.17.2</version>
>           <!--<version>0.16.0</version>-->
>       </dependency>
>
> As you can see, I tried both 0.16.0 and 0.17.2 to no avail. Can you
> please help/show me how to update my pom in order to get the client to
> build on maven.
>
> On a related note, the primary aim of this POC is to figure out how to
> access the ES POJOs for both the request and response. In other words,
> so far, I have been exchanging JSONs between Jersey and ES.
> Consequently, I had to write my own java POJO, and using jackson, to
> convert the returned JSON (from ES rest api) to POJO. I found that to
> be cumbersome.
> Given the following JSON, my guess is that there should be a mapped
> POJO in the public ES API
> {
>   "query": {
>       "filtered" : {
>           "query" : {
>               "query_string" : {
>                   "query" : "some query string here"
>               }
>           },
>           "filter" : {
>               "term" : { "user" : "kimchy" }
>           }
>       }
>   }
> }
> And conversely, the result set JSON should have it's own public POJO.
> Without these public POJOs, I will have to write dozens of POJOs to
> represent the various request and response JSONS.
>
> I my guess correct? If so, can you provide me with the package path.
>
> Thank you for taking the time to help me with these two problems.
>
> ============================================================
>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://
> www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>   <repositories>
>       <!-- Start Jersey Repositories. -->
>       <repository>
>           <id>maven2-repository.java.net</id>
>           <name>Java.net Repository for Maven</name>
>           <url>http://download.java.net/maven/2/</url>
>           <layout>default</layout>
>       </repository>
>       <repository>
>           <id>maven-repository.java.net</id>
>           <name>Java.net Maven 1 Repository (legacy)</name>
>           <url>http://download.java.net/maven/1</url>
>           <layout>legacy</layout>
>       </repository>
>       <!-- End Jersey Repositories. -->
>       <!-- Start ElasticSearch Repositories. -->
>       <repository>
>           <id>oss.sonatype.org</id>
>           <name>OSS Sonatype</name>
>           <releases>
>               <enabled>true</enabled>
>           </releases>
>           <snapshots>
>               <enabled>false</enabled>
>           </snapshots>
>           <url>https://oss.sonatype.org/content/repositories/
> releases/</url>
>       </repository>
>       <repository>
>           <id>sonatype-snapshots</id>
>           <name>Sonatype Snapshots Repository</name>
>           <url>http://oss.sonatype.org/content/repositories/
> snapshots/</url>
>           <snapshots>
>               <enabled>true</enabled>
>           </snapshots>
>       </repository>
>       <!-- Start ElasticSearch Repositories. -->
>   </repositories>
>   <groupId>com.example.es</groupId>
>   <artifactId>es</artifactId>
>   <!--<packaging>jar</packaging>-->
>   <version>1.0-SNAPSHOT</version>
>   <name>es</name>
>   <url>http://maven.apache.org</url>
>   <build>
>       <plugins>
>           <plugin>
>               <groupId>org.apache.maven.plugins</groupId>
>               <artifactId>maven-compiler-plugin</artifactId>
>               <version>2.3.2</version>
>               <configuration>
>                   <source>1.6</source>
>                   <target>1.6</target>
>               </configuration>
>           </plugin>
>
>           <plugin>
>               <artifactId>maven-assembly-plugin</artifactId>
>               <version>2.2.1</version>
>               <configuration>
>                   <descriptorRefs>
>                       <descriptorRef>jar-with-dependencies</
> descriptorRef>
>                   </descriptorRefs>
>                   <archive>
>                       <manifest>
>
> <mainClass>com.example.es.apachehttpclient.Delete</mainClass>
>
> <mainClass>com.example.es.apachehttpclient.Index</mainClass>
>
> <mainClass>com.example.es.apachehttpclient.Search</mainClass>
>                           <mainClass>com.example.es.jersey.Search</
> mainClass>
>                       </manifest>
>                   </archive>
>               </configuration>
>           </plugin>
>       </plugins>
>   </build>
>
>   <dependencies>
>       <!-- Start ElasticSearch Dependencies -->
>       <dependency>
>           <groupId>org.elasticsearch</groupId>
>           <artifactId>elasticsearch</artifactId>
>           <version>0.16.0</version>
>       </dependency>
>       <dependency>
>           <groupId>org.apache.lucene</groupId>
>           <artifactId>lucene-core</artifactId>
>           <version>3.3.0</version>
>       </dependency>
>       <dependency>
>           <groupId>org.apache.lucene</groupId>
>           <artifactId>lucene-analyzers</artifactId>
>           <version>3.3.0</version>
>       </dependency>
>       <dependency>
>           <groupId>org.apache.lucene</groupId>
>           <artifactId>lucene-snowball</artifactId>
>           <version>3.0.3</version>
>       </dependency>
>       <dependency>
>           <groupId>org.apache.lucene</groupId>
>           <artifactId>lucene-fast-vector-highlighter</artifactId>
>           <version>3.0.3</version>
>       </dependency>
>       <dependency>
>           <groupId>org.apache.lucene</groupId>
>           <artifactId>lucene-highlighter</artifactId>
>           <version>2.4.0</version>
>       </dependency>
>       <dependency>
>           <groupId>org.apache.lucene</groupId>
>           <artifactId>lucene-queries</artifactId>
>           <version>2.4.0</version>
>       </dependency>
>       <!-- End ElasticSearch Dependencies -->
>       <!-- Start Jersey Dependencies -->
>       <dependency>
>           <groupId>com.sun.jersey</groupId>
>           <artifactId>jersey-client</artifactId>
>           <version>1.8</version>
>       </dependency>
>       <dependency>
>           <groupId>com.sun.jersey.contribs</groupId>
>           <artifactId>jersey-apache-client</artifactId>
>           <version>1.8</version>
>       </dependency>
>       <!-- End Jersey Dependencies -->
>       <!-- Start Apache Http Client Dependencies -->
>       <dependency>
>           <groupId>org.apache.httpcomponents</groupId>
>           <artifactId>httpclient</artifactId>
>           <version>4.1.1</version>
>       </dependency>
>       <!-- End Apache Http Client Dependencies -->
>       <!-- Start JUNIT Dependencies -->
>       <dependency>
>           <groupId>junit</groupId>
>           <artifactId>junit</artifactId>
>           <version>3.8.2</version>
>           <scope>test</scope>
>       </dependency>
>       <!-- End JUNIT Dependencies -->
>   </dependencies>
> </project>
>

Reply | Threaded
Open this post in threaded view
|

Re: POM for ElasticSearch 0.17.2

Ivan Brusic
In reply to this post by jabawaba-2
What's that? Maven/ivy download issues? Impossible!  That should never happen.  

Oh wait, it does all the time. Repos down, connectivity blips and proxy issues all contribute to tons of hair pulling when using external dependency management.  If your company is large enough, it might make sense to install a maven proxy/cache.

-- 
Ivan

On Wed, Aug 3, 2011 at 2:33 AM, jabawaba <[hidden email]> wrote:
Hi Ivan,

After running it twice with absolutely no changes to the POM or source
code, maven was able to download the jar. Very weird. Can not explain
it.

Thank you for your help.
jabawaba