Skip to content
Snippets Groups Projects
Commit eedf96f6 authored by Emeric Bernet-Rollande's avatar Emeric Bernet-Rollande
Browse files

Update README and remove useless imports

parent 814f8f15
Branches
No related tags found
No related merge requests found
......@@ -3,7 +3,9 @@
The projet consists in two Java classes to perform queries into Datafari/Solr.
The current code needs to be updated in order to work on modern versions of Datafari/Solr.
The current code in SolrTestThreads.java needs to be updated in order to work on modern versions of Solr.
The DatadariTestThreads.java performs queries specified in query_datafari.txt to the Datafari API
The txt files need to be filled with queries that will be sent to Solr/Datafari.
......@@ -12,28 +14,19 @@ To find the top 1000 terms on the index :
We use the terms component.
We had to add this in the solrconfig.xml file :
```
<searchComponent name="terms" class="solr.TermsComponent"/>
<!-- A request handler for demonstrating the terms component -->
<requestHandler name="/terms" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<bool name="terms">true</bool>
<bool name="distrib">true</bool>
</lst>
<arr name="components">
<str>terms</str>
</arr>
</requestHandler>
```
We obtain a list like that : "indic":100381, "joint":100212, "serv":99980, "mision":99952, "identific":99943
......
......@@ -8,13 +8,15 @@ import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import org.json.JSONException;
import org.json.JSONObject;
class RunnableDemo implements Runnable {
private Thread t;
private final String threadName;
private final String BASE_URL = "https://datafaritest.datafari.com/Datafari/rest/v2.0/search/select";
private static final String BASE_URL = "https://datafaritest.datafari.com/Datafari/rest/v2.0/search/select";
private static final String TXT_FILE = "/work/workspace/datafari-load-testing/src/query_datafari.txt";
RunnableDemo( String name) {
threadName = name;
......@@ -35,7 +37,7 @@ class RunnableDemo implements Runnable {
double globalTime = 0.0;
try {
is = new FileInputStream("/data/workspace/datafari-load-testing/src/query_datafari.txt");
is = new FileInputStream(TXT_FILE);
} catch (Exception e){
e.printStackTrace();
......@@ -44,11 +46,14 @@ class RunnableDemo implements Runnable {
try (BufferedReader br = new BufferedReader(new InputStreamReader(is));) {
String line;
String url;
String params = "&fl=title%2Curl%2Cid%2Cextension%2Cpreview_content%2Clast_modified%2Ccrawl_date%2Cauthor%2Coriginal_file_size%2Cemptied%2Crepo_source";
String body = "{}";
while ((line = br.readLine()) != null) {
// Writing HTTP query
url = baseUrl + line;
url = baseUrl + line + params;
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.GET()
......@@ -60,14 +65,16 @@ class RunnableDemo implements Runnable {
try {
response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
String body = response.body();
body = response.body();
JSONObject obj = new JSONObject(body);
int qtime = obj.getJSONObject("responseHeader").getInt("QTime");
nbLines++;
globalTime += qtime;
} catch (IOException | InterruptedException e) {
} catch (IOException | InterruptedException |JSONException e) {
System.out.println("Thread " + threadName + " - Erreur sur la query : " + url);
System.out.println("Thread " + threadName + " - Erreur sur la query : " + body);
e.printStackTrace();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment