- java.lang.Object
-
- com.erudika.para.core.search.MockSearch
-
-
Constructor Summary
Constructors Constructor Description MockSearch()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <P extends ParaObject>
PfindById(String id)Simple id search.<P extends ParaObject>
PfindById(String appid, String id)Simple id search.<P extends ParaObject>
List<P>findByIds(String appid, List<String> ids)Simple multi id search.<P extends ParaObject>
List<P>findByIds(List<String> ids)Simple multi id search.<P extends ParaObject>
List<P>findNearby(String type, String query, int radius, double lat, double lng, Pager... pager)Search forAddressobjects in a radius of X km from a given point.<P extends ParaObject>
List<P>findNearby(String appid, String type, String query, int radius, double lat, double lng, Pager... pager)Search forAddressobjects in a radius of X km from a given point.<P extends ParaObject>
List<P>findNestedQuery(String type, String field, String query, Pager... pager)Searches within a nested field.<P extends ParaObject>
List<P>findNestedQuery(String appid, String type, String field, String query, Pager... pager)Searches within a nested field.<P extends ParaObject>
List<P>findPrefix(String type, String field, String prefix, Pager... pager)Searches for objects that have a property which value starts with a given prefix.<P extends ParaObject>
List<P>findPrefix(String appid, String type, String field, String prefix, Pager... pager)Searches for objects that have a property which value starts with a given prefix.<P extends ParaObject>
List<P>findQuery(String type, String query, Pager... pager)Query string search.<P extends ParaObject>
List<P>findQuery(String appid, String type, String query, Pager... pager)Query string search.<P extends ParaObject>
List<P>findSimilar(String type, String filterKey, String[] fields, String liketext, Pager... pager)Searches for objects that have similar property values to a given text.<P extends ParaObject>
List<P>findSimilar(String appid, String type, String filterKey, String[] fields, String liketext, Pager... pager)Searches for objects that have similar property values to a given text.<P extends ParaObject>
List<P>findTagged(String type, String[] tags, Pager... pager)Searches for objects tagged with one or more tags.<P extends ParaObject>
List<P>findTagged(String appid, String type, String[] tags, Pager... pager)Searches for objects tagged with one or more tags.<P extends ParaObject>
List<P>findTags(String keyword, Pager... pager)Searches forTagobjects.<P extends ParaObject>
List<P>findTags(String appid, String keyword, Pager... pager)Searches forTagobjects.<P extends ParaObject>
List<P>findTermInList(String appid, String type, String field, List<?> terms, Pager... pager)Searches for objects having a property value that is in list of possible values.<P extends ParaObject>
List<P>findTermInList(String type, String field, List<?> terms, Pager... pager)Searches for objects having a property value that is in list of possible values.<P extends ParaObject>
List<P>findTerms(String appid, String type, Map<String,?> terms, boolean matchAll, Pager... pager)Searches for objects that have properties matching some given values.<P extends ParaObject>
List<P>findTerms(String type, Map<String,?> terms, boolean matchAll, Pager... pager)Searches for objects that have properties matching some given values.<P extends ParaObject>
List<P>findWildcard(String type, String field, String wildcard, Pager... pager)Searches for objects that have a property with a value matching a wildcard query.<P extends ParaObject>
List<P>findWildcard(String appid, String type, String field, String wildcard, Pager... pager)Searches for objects that have a property with a value matching a wildcard query.LonggetCount(String type)Counts indexed objects.LonggetCount(String appid, String type)Counts indexed objects.LonggetCount(String appid, String type, Map<String,?> terms)Counts indexed objects matching a set of terms/values.LonggetCount(String type, Map<String,?> terms)Counts indexed objects matching a set of terms/values.voidindex(ParaObject po)Indexes an object.voidindex(String appid, ParaObject po)Indexes an object.<P extends ParaObject>
voidindexAll(String appid, List<P> objects)Indexes multiple objects in a batch operation.<P extends ParaObject>
voidindexAll(List<P> objects)Indexes multiple objects in a batch operation.booleanisValidQueryString(String queryString)Validates a query string.booleanrebuildIndex(DAO dao, App app, Pager... pager)Reads all objects from the database and indexes them into a new index.booleanrebuildIndex(DAO dao, App app, String destinationIndex, Pager... pager)Reads all objects from the database and indexes them into a new index.voidunindex(ParaObject po)Removes an object from the index.voidunindex(String appid, ParaObject po)Removes an object from the index.<P extends ParaObject>
voidunindexAll(String appid, List<P> objects)Removes multiple objects from the index in a batch operation.voidunindexAll(String appid, Map<String,?> terms, boolean matchAll)Removes multiple objects from the index matching a set of terms.<P extends ParaObject>
voidunindexAll(List<P> objects)Removes multiple objects from the index in a batch operation.voidunindexAll(Map<String,?> terms, boolean matchAll)Removes multiple objects from the index matching a set of terms.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.erudika.para.core.search.Search
createIndex, deleteIndex
-
-
-
-
Method Detail
-
index
public void index(ParaObject po)
Description copied from interface:SearchIndexes an object. Only fields marked withStoredare indexed.
-
index
public void index(String appid, ParaObject po)
Description copied from interface:SearchIndexes an object. Only fields marked withStoredare indexed.
-
unindex
public void unindex(ParaObject po)
Description copied from interface:SearchRemoves an object from the index.
-
unindex
public void unindex(String appid, ParaObject po)
Description copied from interface:SearchRemoves an object from the index.
-
indexAll
public <P extends ParaObject> void indexAll(List<P> objects)
Description copied from interface:SearchIndexes multiple objects in a batch operation.
-
indexAll
public <P extends ParaObject> void indexAll(String appid, List<P> objects)
Description copied from interface:SearchIndexes multiple objects in a batch operation.
-
unindexAll
public <P extends ParaObject> void unindexAll(List<P> objects)
Description copied from interface:SearchRemoves multiple objects from the index in a batch operation.- Specified by:
unindexAllin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
objects- a list of objects
-
unindexAll
public <P extends ParaObject> void unindexAll(String appid, List<P> objects)
Description copied from interface:SearchRemoves multiple objects from the index in a batch operation.- Specified by:
unindexAllin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
appid- name of theAppobjects- a list of objects
-
unindexAll
public void unindexAll(Map<String,?> terms, boolean matchAll)
Description copied from interface:SearchRemoves multiple objects from the index matching a set of terms.- Specified by:
unindexAllin interfaceSearch- Parameters:
terms- a list of termsmatchAll- if true all terms must match ('AND' operation)
-
unindexAll
public void unindexAll(String appid, Map<String,?> terms, boolean matchAll)
Description copied from interface:SearchRemoves multiple objects from the index matching a set of terms. If the terms parameter is empty or null, all objects should be removed from index.- Specified by:
unindexAllin interfaceSearch- Parameters:
appid- name of theAppterms- a list of termsmatchAll- if true all terms must match ('AND' operation)
-
findById
public <P extends ParaObject> P findById(String id)
Description copied from interface:SearchSimple id search.
-
findById
public <P extends ParaObject> P findById(String appid, String id)
Description copied from interface:SearchSimple id search.
-
findByIds
public <P extends ParaObject> List<P> findByIds(List<String> ids)
Description copied from interface:SearchSimple multi id search.
-
findByIds
public <P extends ParaObject> List<P> findByIds(String appid, List<String> ids)
Description copied from interface:SearchSimple multi id search.
-
findNearby
public <P extends ParaObject> List<P> findNearby(String type, String query, int radius, double lat, double lng, Pager... pager)
Description copied from interface:SearchSearch forAddressobjects in a radius of X km from a given point.- Specified by:
findNearbyin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
type- the type of object to search for. SeeParaObject.getType()query- the query stringradius- the radius of the search circlelat- latitudelng- longitudepager- aPager- Returns:
- a list of objects found
-
findNearby
public <P extends ParaObject> List<P> findNearby(String appid, String type, String query, int radius, double lat, double lng, Pager... pager)
Description copied from interface:SearchSearch forAddressobjects in a radius of X km from a given point.- Specified by:
findNearbyin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
appid- name of theApptype- the type of object to search for. SeeParaObject.getType()query- the query stringradius- the radius of the search circlelat- latitudelng- longitudepager- aPager- Returns:
- a list of objects found
-
findPrefix
public <P extends ParaObject> List<P> findPrefix(String type, String field, String prefix, Pager... pager)
Description copied from interface:SearchSearches for objects that have a property which value starts with a given prefix.- Specified by:
findPrefixin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
type- the type of object to search for. SeeParaObject.getType()field- the property name of an objectprefix- the prefixpager- aPager- Returns:
- a list of objects found
-
findPrefix
public <P extends ParaObject> List<P> findPrefix(String appid, String type, String field, String prefix, Pager... pager)
Description copied from interface:SearchSearches for objects that have a property which value starts with a given prefix.- Specified by:
findPrefixin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
appid- name of theApptype- the type of object to search for. SeeParaObject.getType()field- the property name of an objectprefix- the prefixpager- aPager- Returns:
- a list of objects found
-
findQuery
public <P extends ParaObject> List<P> findQuery(String type, String query, Pager... pager)
Description copied from interface:SearchQuery string search. This is the basic search method. Refer to the Lucene query string syntax.- Specified by:
findQueryin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
type- the type of object to search for. SeeParaObject.getType()query- the query stringpager- aPager- Returns:
- a list of objects found
-
findQuery
public <P extends ParaObject> List<P> findQuery(String appid, String type, String query, Pager... pager)
Description copied from interface:SearchQuery string search. This is the basic search method. Refer to the Lucene query string syntax.- Specified by:
findQueryin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
appid- name of theApptype- the type of object to search for. SeeParaObject.getType()query- the query stringpager- aPager- Returns:
- a list of objects found
-
findNestedQuery
public <P extends ParaObject> List<P> findNestedQuery(String type, String field, String query, Pager... pager)
Description copied from interface:SearchSearches within a nested field. The objects of the given type must contain a nested field "nstd".- Specified by:
findNestedQueryin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
type- the type of object to search for. SeeParaObject.getType()field- the name of the field to target (within a nested field "nstd")query- query stringpager- aPager- Returns:
- list of objects found
-
findNestedQuery
public <P extends ParaObject> List<P> findNestedQuery(String appid, String type, String field, String query, Pager... pager)
Description copied from interface:SearchSearches within a nested field. The objects of the given type must contain a nested field "nstd".- Specified by:
findNestedQueryin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
appid- name of theApptype- the type of object to search for. SeeParaObject.getType()field- the name of the field to target (within a nested field "nstd")query- query stringpager- aPager- Returns:
- list of objects found
-
findSimilar
public <P extends ParaObject> List<P> findSimilar(String type, String filterKey, String[] fields, String liketext, Pager... pager)
Description copied from interface:SearchSearches for objects that have similar property values to a given text. A "find like this" query.- Specified by:
findSimilarin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
type- the type of object to search for. SeeParaObject.getType()filterKey- exclude an object with this key from the results (optional)fields- a list of property namesliketext- text to compare topager- aPager- Returns:
- a list of objects found
-
findSimilar
public <P extends ParaObject> List<P> findSimilar(String appid, String type, String filterKey, String[] fields, String liketext, Pager... pager)
Description copied from interface:SearchSearches for objects that have similar property values to a given text. A "find like this" query.- Specified by:
findSimilarin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
appid- name of theApptype- the type of object to search for. SeeParaObject.getType()filterKey- exclude an object with this key from the results (optional)fields- a list of property namesliketext- text to compare topager- aPager- Returns:
- a list of objects found
-
findTagged
public <P extends ParaObject> List<P> findTagged(String type, String[] tags, Pager... pager)
Description copied from interface:SearchSearches for objects tagged with one or more tags.- Specified by:
findTaggedin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
type- the type of object to search for. SeeParaObject.getType()tags- the list of tagspager- aPager- Returns:
- a list of objects found
-
findTagged
public <P extends ParaObject> List<P> findTagged(String appid, String type, String[] tags, Pager... pager)
Description copied from interface:SearchSearches for objects tagged with one or more tags.- Specified by:
findTaggedin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
appid- name of theApptype- the type of object to search for. SeeParaObject.getType()tags- the list of tagspager- aPager- Returns:
- a list of objects found
-
findTags
public <P extends ParaObject> List<P> findTags(String keyword, Pager... pager)
Description copied from interface:SearchSearches forTagobjects. This method might be deprecated in the future.
-
findTags
public <P extends ParaObject> List<P> findTags(String appid, String keyword, Pager... pager)
Description copied from interface:SearchSearches forTagobjects. This method might be deprecated in the future.
-
findTermInList
public <P extends ParaObject> List<P> findTermInList(String type, String field, List<?> terms, Pager... pager)
Description copied from interface:SearchSearches for objects having a property value that is in list of possible values.- Specified by:
findTermInListin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
type- the type of object to search for. SeeParaObject.getType()field- the property name of an objectterms- a list of terms (property values)pager- aPager- Returns:
- a list of objects found
-
findTermInList
public <P extends ParaObject> List<P> findTermInList(String appid, String type, String field, List<?> terms, Pager... pager)
Description copied from interface:SearchSearches for objects having a property value that is in list of possible values.- Specified by:
findTermInListin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
appid- name of theApptype- the type of object to search for. SeeParaObject.getType()field- the property name of an objectterms- a list of terms (property values)pager- aPager- Returns:
- a list of objects found
-
findTerms
public <P extends ParaObject> List<P> findTerms(String type, Map<String,?> terms, boolean matchAll, Pager... pager)
Description copied from interface:SearchSearches for objects that have properties matching some given values. A terms query.- Specified by:
findTermsin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
type- the type of object to search for. SeeParaObject.getType()terms- a map of fields (property names) to terms (property values)matchAll- match all terms. If true - AND search, if false - OR searchpager- aPager- Returns:
- a list of objects found
-
findTerms
public <P extends ParaObject> List<P> findTerms(String appid, String type, Map<String,?> terms, boolean matchAll, Pager... pager)
Description copied from interface:SearchSearches for objects that have properties matching some given values. A terms query.- Specified by:
findTermsin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
appid- name of theApptype- the type of object to search for. SeeParaObject.getType()terms- a map of fields (property names) to terms (property values)matchAll- match all terms. If true - AND search, if false - OR searchpager- aPager- Returns:
- a list of objects found
-
findWildcard
public <P extends ParaObject> List<P> findWildcard(String type, String field, String wildcard, Pager... pager)
Description copied from interface:SearchSearches for objects that have a property with a value matching a wildcard query.- Specified by:
findWildcardin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
type- the type of object to search for. SeeParaObject.getType()field- the property name of an objectwildcard- wildcard query string. For example "cat*".pager- aPager- Returns:
- a list of objects found
-
findWildcard
public <P extends ParaObject> List<P> findWildcard(String appid, String type, String field, String wildcard, Pager... pager)
Description copied from interface:SearchSearches for objects that have a property with a value matching a wildcard query.- Specified by:
findWildcardin interfaceSearch- Type Parameters:
P- type of the object- Parameters:
appid- name of theApptype- the type of object to search for. SeeParaObject.getType()field- the property name of an objectwildcard- wildcard query string. For example "cat*".pager- aPager- Returns:
- a list of objects found
-
getCount
public Long getCount(String type)
Description copied from interface:SearchCounts indexed objects.- Specified by:
getCountin interfaceSearch- Parameters:
type- the type of object to search for. SeeParaObject.getType()- Returns:
- the number of results found
-
getCount
public Long getCount(String appid, String type)
Description copied from interface:SearchCounts indexed objects.- Specified by:
getCountin interfaceSearch- Parameters:
appid- name of theApptype- the type of object to search for. SeeParaObject.getType()- Returns:
- the number of results found
-
getCount
public Long getCount(String type, Map<String,?> terms)
Description copied from interface:SearchCounts indexed objects matching a set of terms/values.- Specified by:
getCountin interfaceSearch- Parameters:
type- the type of object to search for. SeeParaObject.getType()terms- a list of terms (property values)- Returns:
- the number of results found
-
getCount
public Long getCount(String appid, String type, Map<String,?> terms)
Description copied from interface:SearchCounts indexed objects matching a set of terms/values.- Specified by:
getCountin interfaceSearch- Parameters:
appid- name of theApptype- the type of object to search for. SeeParaObject.getType()terms- a map of fields (property names) to terms (property values)- Returns:
- the number of results found
-
rebuildIndex
public boolean rebuildIndex(DAO dao, App app, Pager... pager)
Description copied from interface:SearchReads all objects from the database and indexes them into a new index. Old index is usually deleted.- Specified by:
rebuildIndexin interfaceSearch- Parameters:
dao- aDAOimplementationapp- anAppobjectpager- aPagerobject- Returns:
- true if operation was successful
-
rebuildIndex
public boolean rebuildIndex(DAO dao, App app, String destinationIndex, Pager... pager)
Description copied from interface:SearchReads all objects from the database and indexes them into a new index. Old index is usually deleted.- Specified by:
rebuildIndexin interfaceSearch- Parameters:
dao- aDAOimplementationapp- anAppobjectdestinationIndex- the name of an existing index where data will be reindexed topager- aPagerobject- Returns:
- true if operation was successful
-
isValidQueryString
public boolean isValidQueryString(String queryString)
Description copied from interface:SearchValidates a query string.- Specified by:
isValidQueryStringin interfaceSearch- Parameters:
queryString- a query string- Returns:
- true if query is valid
-
-