undefined method - geoBoundingBoxQuery(String location) - java

I am trying to create a geoBoundingBoxQuery("pin.location") in Java for Elastic Search. Eclipse is not able to resolve imports for this method although the Elastic Search Java API documentation specifically suggests to use this method.
What class do I need to import which has this method?
https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-geo-queries.html#java-query-dsl-geo-bounding-box-query

geoBoundingBoxQuery("pin.location") is defined as a static method in class org.elasticsearch.index.query.QueryBuilders, so you can use it this way:
QueryBuilder q = QueryBuilders.geoBoundingBoxQuery("pin.location");
Elasticsearch documentation is assuming you're using a static import like:
import static org.elasticsearch.index.query.QueryBuilders.geoBoundingBoxQuery;
so you don't need qualify the method with class name:
QueryBuilder q = geoBoundingBoxQuery("pin.location");

For anyone who is having the same issue, I have found the answer.
Its the version of Elastic search java API that I am using is the issue. The documentation is for version 2.1 whereas I am using an older version. For the older version, you need to do the following:
FilterBuilders.geoBoundingBoxFilter("pin.location")

Related

gremlin order by query with incr

g.V().has(label,"request_job").order().by("submit_time",incr).valueMap("submit_time")
==>[submit_time:[1330647978000]]
==>[submit_time:[1330652298000]]
When I use, order() query in Gremlin console, it is working fine. But when I try the same query in Java, I am not able to use "incr", it is showing that undefined symbol "incr".
How to use "incr" with order() in Java?
Kindly help me to resolve this problem.
It is defined in the enum Order (javadoc) which is automatically imported by the Gremlin Console. You should add the following import to your Java class:
import static org.apache.tinkerpop.gremlin.process.traversal.Order.*;

In GWT is the 2.5 interface RpcService replaced by RemoteService interface?

I'm currently going through the book GWT in Action 2nd Edition and its example code. In chapter 5 under the discussions on ClientBundle usage they have example code where there is an interface that extends com.google.gwt.rpc.client.RpcService. When I loaded this example project into my Eclipse IDE, the code shows red as the package com.google.gwt.rpc does not exist. This is most likely because I'm using GWT 2.7 and the book was written back in GWT 2.5. I attempted to look into the JavaDoc to see when it was removed, and what its replacement should be, but the only JavaDoc is for the latest, and downloads for 2.5 from the website returns no page found (404) errors. My IDE is suggesting that I change the requested interface to com.google.gwt.user.client.rpc.RemoteService but without knowing if this is the correct replacement, it seems a bit odd.
The code example they provide is as follows:
package com.manning.gwtia.ch05.client.cssresource;
import java.util.HashMap;
import java.util.List;
import com.google.gwt.rpc.client.RpcService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
#RemoteServiceRelativePath("CSSResourceService")
public interface ResourceService extends RpcService {
List<String> getThemes();
HashMap<String, String> getTheme(String name);
}
Does anyone know what the proper replacement interface for RpcService and maybe also tell me in which version it was removed?
com.google.gwt.rpc was an experiment aimed at replacing RPC from com.google.gwt.user. It didn't met expectations and was ultimately removed in 2.7. So yes, use RemoteService, like you should have actually always done.

MongoDB updates with java driver version 3.0

I'm migrating my aplications to MongoDb 3.0.2. I have no problems with inserts, finds and deletes. But,Problems with the update. Specially with the eq().
In this sentence:
coll.updateOne(eq("_id", id), new Document("$set", new Document("name", name)));
The id variable is defined ObjectId. Eclipse gives me an error:
The method eq(String, ObjectId) is undefined for the
type SystemDAO (my java class).
What am I doing wrong? I followed the examples in the Mongo java driver documents.
you need to import the static method eq from the package com.mongodb.client.model.Filters.
add this infront of your class to your other imports:
import static com.mongodb.client.model.Filters.*;
In Eclipse it should give a quick-fix to import the right package if you do a mouse over on your error. But for static imports this does not work all the time.

CompilationTestHelper is either not found or its access discouraged

I want to write some tests for my compiler but can't get past an error.
I'm following an example from 'Implementing DSL with Xtext and Xtend' by L. Bettini (great book btw). I've downloaded the code for the 'entities' DSL from https://github.com/LorenzoBettini/packtpub-xtext-book-examples and the tests in EntitiesGenerator.xtend work great.
If I write a test for the default DSL (MyDsl) using the same code, I've got an error:
org.eclipse.xtext.xbase.compiler.CompilationTestHelper cannot be resolved to a type.
or, if I add org.eclipse.xtext.xbase.junit (2.4.1) to the list of required plug-ins, I get
Discouraged access: The type CompilationTestHelper is not accessible due to restriction on required project org.xtext.example.myDsl.tests
I can allow access to it, but then get a runtime error anyway. If I try to add org.eclipse.xtext.xbase.lib as well, only org.eclipse.xtext.xbase.lib.source appears in the list. I don't know it that matters. In any case, adding it doesn't change anything.
What do I need to do to make it work?
I'm using Juno with Xtext 2.4.1., Java 1.7.
The content of the test class:
package org.xtext.example.myDsl.tests
import com.google.inject.Inject
import org.eclipse.xtext.junit4.InjectWith
import org.eclipse.xtext.junit4.XtextRunner
import org.eclipse.xtext.xbase.compiler.CompilationTestHelper // error here
import org.xtext.example.myDsl.MyDslInjectorProvider
import org.junit.Test
import org.junit.runner.RunWith
#RunWith(typeof(XtextRunner))
#InjectWith(typeof(MyDslInjectorProvider))
class MyDslGeneratorTest {
#Inject extension CompilationTestHelper
#Test
def void testGeneratedCode() {
'''
Hello some1!
Hello some2!
'''.assertCompilesTo(
'''some content''')
}
}
Thank you in advance!
the xtext guys mark stuff that may be changed NOT as api. this is why you get this warning.
it should work anyway. (although it is meant to be used for xbase languages only)
P.S: you have to add a dependency to jdt.core too

Solr 4.0 and ResourceLoader: getLines undefined

I'm translating to Lucene 4.0 a plug-in developed over Lucene 3.6, but I'm having so much troubles with ResourceLoader.
I've changed the imports related to ResourceLoader from:
import org.apache.solr.common.ResourceLoader;
import org.apache.solr.util.plugin.ResourceLoaderAware;
to:
import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.lucene.analysis.util.ResourceLoaderAware;
But at the inform method:
public void inform(ResourceLoader loader) {
when I try to use the getLines function:
List list = loader.getLines("file");
I get the following error:
The method getLines(String) is undefined for the type ResourceLoader
What am I doing wrong?
Kind regards
At Lucene 4.0, getLines doesn't have to be invoked as a method from ResourceLoader.
Here you can see an example.

Categories