<commit_before>package uk.ac.ebi.phis.service;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.response.Group;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Service;

import uk.ac.ebi.phis.solrj.dto.AutosuggestDTO;
import uk.ac.ebi.phis.solrj.dto.AutosuggestTypes;
import uk.ac.ebi.phis.solrj.dto.ImageDTO;

@Service
public class AutosuggestService extends BasicService {

	private static final Logger log = Logger.getLogger(ImageService.class);

	public AutosuggestService(String solrUrl) {
		super(solrUrl);
	}


	public String getAutosuggest(String term, AutosuggestTypes type, String stage, String imagingMethod, String taxon, String sampleType, String imageGeneratedBy, Integer rows) {

		SolrQuery solrQuery = new SolrQuery();
		ArrayList<String> suggestions = new ArrayList<>();

		solrQuery.setQuery(term);
		solrQuery.setFields(ImageDTO.TERM_AUTOSUGGEST);
		solrQuery.set("defType", "edismax");
		solrQuery.set("group", true);
		solrQuery.set("group.field", "term_autosuggest_na");
		solrQuery.set("qf", "term_autosuggest term_autosuggest_ws term_autosuggest_e term_autosuggest_na");
		solrQuery.set("bq", "term_autosuggest_ws:\"" + term +
		"\"^2 term_autosuggest_e:\"" + term + "\"^3 term_autosuggest_na:\"" + term + "\"^4 term_autosuggest_ws:\"" + term + "\"^1");<commit_msg>Fixed autosuggest query <commit_after>package uk.ac.ebi.phis.service;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.response.Group;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Service;

import uk.ac.ebi.phis.solrj.dto.AutosuggestDTO;
import uk.ac.ebi.phis.solrj.dto.AutosuggestTypes;
import uk.ac.ebi.phis.solrj.dto.ImageDTO;

@Service
public class AutosuggestService extends BasicService {

	private static final Logger log = Logger.getLogger(ImageService.class);

	public AutosuggestService(String solrUrl) {
		super(solrUrl);
	}


	public String getAutosuggest(String term, AutosuggestTypes type, String stage, String imagingMethod, String taxon, String sampleType, String imageGeneratedBy, Integer rows) {

		SolrQuery solrQuery = new SolrQuery();
		ArrayList<String> suggestions = new ArrayList<>();

		solrQuery.setQuery(term);
		solrQuery.setFields(ImageDTO.TERM_AUTOSUGGEST);
		solrQuery.set("defType", "edismax");
		solrQuery.set("group", true);
		solrQuery.set("group.field", "term_autosuggest_na");
		solrQuery.set("qf", "term_autosuggest term_autosuggest_ws term_autosuggest_e term_autosuggest_na");
		solrQuery.set("bq", "term_autosuggest_ws:\"" + term +
		"\"^2 term_autosuggest_e:\"" + term + "\"^3 term_autosuggest_na:\"" + term + "\"^4 term_autosuggest:\"" + term + "\"^1");
{'fraction_non_alphanumeric': 0.12916423144360023, 'fraction_numerical': 0.0029222676797194622, 'mean_word_length': 5.985714285714286, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5107848', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1200, 'n_words': 210}