All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.l4.silo.search.SearchIndexQuery Maven / Gradle / Ivy

The newest version!
package se.l4.silo.search;

import java.util.Locale;
import java.util.function.Supplier;

import se.l4.silo.query.LimitableQuery;
import se.l4.silo.query.Query;
import se.l4.silo.query.QueryType;
import se.l4.silo.search.facet.FacetQueryType;

/**
 * Query for a search index. Support several differents ways to query
 * an index, including {@code and} and {@code or} operators.
 *
 * @author Andreas Holstenson
 *
 * @param 
 */
public interface SearchIndexQuery
	extends Query>,
		LimitableQuery>,
		QueryWithSubqueries, SearchIndexQuery>
{
	static  QueryType, SearchIndexQuery> type()
	{
		return new SearchIndexQueryType<>();
	}

	/**
	 * Set the locale this query is being performed from. This is used for
	 * query parsing in the correct language.
	 *
	 * @param locale
	 * @return
	 */
	SearchIndexQuery fromLocale(Locale locale);

	/**
	 * Indicate that this query should wait for the absolute freshest index
	 * data. By default a search index lags after as reopening the index has
	 * a cost associated with it. Use this method to request that this query
	 * is run against the absolute stored data. This is useful in the
	 * scenario where a user stores something and you need to query for it
	 * directly afterwards.
	 *
	 * @return
	 */
	SearchIndexQuery waitForLatest();

	/**
	 * Define a facet that we should use.
	 *
	 * @param id
	 * @return
	 */
	>> C withFacet(String id, FacetQueryType, C> type);

	/**
	 * Define a facet that we should use.
	 *
	 * @param id
	 * @return
	 */
	>> C withFacet(String id, Supplier facetType);

	/**
	 * Request that this pipeline should sort its results.
	 *
	 * @param sort
	 * @param sortAscending
	 * @return
	 */
	SearchIndexQuery addSort(String sort, boolean sortAscending);

	/**
	 * Request that this pipeline should sort its result with some extra
	 * parameters.
	 *
	 * @param field
	 * @param sorter
	 * @return
	 */
	>> C addSort(String field, Supplier sorter);

	/**
	 * Request that we should use custom scoring.
	 *
	 * @param scoring
	 * @return
	 */
	>> C setScoring(Supplier scoring);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy