Java

Java elasticsearch, find by part of the work

I have small problem with Java elasticsearch (2.3.3) TransportClient client = TransportClient.builder().build() .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(“127.0.0.1”), 9300)); QueryBuilder qb = multiMatchQuery( “org”, // George “firstname”,”lastname” ).fuzziness(Fuzziness.build(2)); SearchResponse response = client.prepareSearch(“user”) .setQuery(qb) .execute() .get(); for(SearchHit hit : response.getHits()){ System.out.println(hit.getSource()); } By fuzziness, I can find when I did not type 2 letters. I want it to find a user by firstname or lastname,…
Read more

Completness of multiple selects

I have a table of data (100k-1M rows). The most important attribute is “price”. Users make division of the total sum of price into various groups by custom queries, that pick data from the table. Queries have no pattern – their WHERE clause is made of different conditions. Question: how can I determine, that list of queries is complete –…
Read more

How to resize an image when it’s scrolled over in android?

Currently i’m using RecyclerView to display 3 images horizontally. I would like the view to look like so: Scrollable layout So that when I scroll to the left/right the images resize depending on their position in the row (centre image being the largest). Is there a way to do this in android, using RecylcerView or something else? Thank you for…
Read more

Data Not Displaying Correctly On JFreeChart

Loading data from a text file and displaying it on a JFreeChart. However, the data is not plotted on the graph and the Y Axis is not labelled correctly using the highest and lowest values from the dataset of the text file. Would be hugely appreciated if someone could add the code to correct this problem! Text File is formatted…
Read more

Eclipse maven Parent of resource marked as read only

I get the following error when I try to add/refactor a class: Parent of resource: /Users/Mike/git/switch-ingredients/maven/src/main/java/org/apache/maven/maven/Client.java is marked as read only. I have tried to give permissions to the files(chmod 777), I tried to restart eclipse and change the build path, but no success. What should I do? Thanks! Source: java

How to print distinct array elements in java?

here’s the code for printing distinct elements from a list of elements in an array(I got this from a website). package pattern; import java.util.*; class Pattern{ public static void main(String[] args){ int[] num=new int[6]; //method to enter elements inside ‘num’ array System.out.println(“Enter the numbers: “); getEle(num); //method to print distinct elements from array System.out.println(“Printing distinct elements:”); printDis(num); } public static…
Read more

How to deserialize a list of objects with different names to same pojo

I have the following different JSONs { “item”: [ { “Retailer_Relation”: {…}, “Retailer_Relation”: {…}, “Retailer_Relation”: {…} } } and { “item”: [ { “Retailer”: {…}, “Retailer”: {…}, “Retailer”: {…} } } And the following class into which I deserialize the JSONs. This obviously only works for the second of the JSONs. However, I would like the JSON containing Retailer_Relation objects…
Read more

Java boolean return if statement

Can someone please explain, in simple English, the logic behind this statement? return mContainsLoadingRow ? (getContentDataSize() + 1) : getContentDataSize(); Assuming mContainsLoadingRow is a boolean, if mContainsLoadingRow is true, then return getContentDataSize() + 1? If not, return getContentDataSize()? Is that the correct way to look at this? Source: java

Gson custom deserialization but only one field

I’m receiving from API long json, e.g.: { “field1”: “val1”, “field2”: “val2”, … “SOME_FIELD”: ” ABC “, … “fieldx”: “valx” } I would like to deserialize it with Gson. Everything works fine but field’s “SOME_FIELD” value is always with annoying spaces. I would like to trim() this field value (API can’t be changed). I know I can use JsonDeserializer but…
Read more