Search
Contents
[
Hide
]
Search(string)
Searches in index.
public SearchResult Search(string query)
Parameter | Type | Description |
---|---|---|
query | String | The search query. |
Return Value
The search result.
Examples
The following example demonstrates how to perform simple search.
string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
string query = "Einstein";
Index index = new Index(indexFolder); // Creating index in the specified folder
index.Add(documentsFolder); // Indexing documents from the specified folder
SearchResult result = index.Search(query); // Searching
The following example demonstrates how to perform Regex search.
string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
Index index = new Index(indexFolder); // Creating index in the specified folder
index.Add(documentsFolder); // Indexing documents from the specified folder
string query = "^[0-9]{3,}"; // The caret symbol at the beginning of the search query tells the index that it is a Regex query
SearchResult result = index.Search(query); // Searching
The following example demonstrates how to perform faceted search.
string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
Index index = new Index(indexFolder); // Creating index in the specified folder
index.Add(documentsFolder); // Indexing documents from the specified folder
string query = "content:Newton"; // The word before the colon in the query means the document field name to search
SearchResult result = index.Search(query); // Searching
See Also
- class SearchResult
- class Index
- namespace GroupDocs.Search
- assembly GroupDocs.Search
Search(string, SearchOptions)
Searches in index.
public SearchResult Search(string query, SearchOptions options)
Parameter | Type | Description |
---|---|---|
query | String | The search query. |
options | SearchOptions | The search options. |
Return Value
The search result.
Examples
The following example demonstrates how to perform fuzzy search.
string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
Index index = new Index(indexFolder); // Creating index in the specified folder
index.Add(documentsFolder); // Indexing documents from the specified folder
SearchOptions options = new SearchOptions();
options.FuzzySearch.Enabled = true; // Enabling the fuzzy search
options.FuzzySearch.FuzzyAlgorithm = new TableDiscreteFunction(1); // Setting the number of possible differences for each word
// Double quotes at the beginning and end tells the index that it is phrase search query
string query = "\"The Pursuit of Happiness\"";
SearchResult result = index.Search(query, options); // Searching
The following example demonstrates how to perform synonym search.
string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
Index index = new Index(indexFolder); // Creating index in the specified folder
index.Add(documentsFolder); // Indexing documents from the specified folder
SearchOptions options = new SearchOptions();
options.UseSynonymSearch = true; // Enabling the synonym search
string query = "cry";
SearchResult result = index.Search(query, options); // Searching
See Also
- class SearchResult
- class SearchOptions
- class Index
- namespace GroupDocs.Search
- assembly GroupDocs.Search
Search(SearchQuery)
Searches in index.
public SearchResult Search(SearchQuery query)
Parameter | Type | Description |
---|---|---|
query | SearchQuery | The search query. |
Return Value
The search result.
Examples
The following example demonstrates how to perform search using query in object form.
string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
Index index = new Index(indexFolder); // Creating index in the specified folder
index.Add(documentsFolder); // Indexing documents from the specified folder
// Creating subquery 1
SearchQuery subquery1 = SearchQuery.CreateWordQuery("accommodation");
subquery1.SearchOptions = new SearchOptions(); // Setting search options only for subquery 1
subquery1.SearchOptions.FuzzySearch.Enabled = true; // Enabling the fuzzy search
subquery1.SearchOptions.FuzzySearch.FuzzyAlgorithm = new TableDiscreteFunction(3); // Setting maximum number of differences
// Creating subquery 2
SearchQuery subquery2 = SearchQuery.CreateNumericRangeQuery(1, 1000000);
// Creating subquery 3
SearchQuery subquery3 = SearchQuery.CreateRegexQuery(@"(.)\1");
// Combining subqueries into one query
SearchQuery query = SearchQuery.CreatePhraseSearchQuery(subquery1, subquery2, subquery3);
SearchResult result = index.Search(query); // Searching
See Also
- class SearchResult
- class SearchQuery
- class Index
- namespace GroupDocs.Search
- assembly GroupDocs.Search
Search(SearchQuery, SearchOptions)
Searches in index.
public SearchResult Search(SearchQuery query, SearchOptions options)
Parameter | Type | Description |
---|---|---|
query | SearchQuery | The search query. |
options | SearchOptions | The search options. |
Return Value
The search result.
Examples
The following example demonstrates how to perform search using query in object form.
string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
Index index = new Index(indexFolder); // Creating index in the specified folder
index.Add(documentsFolder); // Indexing documents from the specified folder
// Creating subquery of date range search
SearchQuery subquery1 = SearchQuery.CreateDateRangeQuery(new DateTime(2011, 6, 17), new DateTime(2013, 1, 1));
// Creating subquery of wildcard with number of missed words from 0 to 2
SearchQuery subquery2 = SearchQuery.CreateWildcardQuery(0, 2);
// Creating subquery of simple word
SearchQuery subquery3 = SearchQuery.CreateWordQuery("birth");
subquery3.SearchOptions = new SearchOptions(); // Setting search options only for subquery 3
subquery3.SearchOptions.FuzzySearch.Enabled = true;
subquery3.SearchOptions.FuzzySearch.FuzzyAlgorithm = new TableDiscreteFunction(1);
// Combining subqueries into one query
SearchQuery query = SearchQuery.CreatePhraseSearchQuery(subquery1, subquery2, subquery3);
// Creating search options object with increased capacity of found occurrences
SearchOptions options = new SearchOptions(); // Overall search options
options.MaxOccurrenceCountPerTerm = 1000000;
options.MaxTotalOccurrenceCount = 10000000;
SearchResult result = index.Search(query, options); // Searching
See Also
- class SearchResult
- class SearchQuery
- class SearchOptions
- class Index
- namespace GroupDocs.Search
- assembly GroupDocs.Search
Search(SearchImage, ImageSearchOptions)
Performs a reverse image search in the index.
public ImageSearchResult Search(SearchImage image, ImageSearchOptions options)
Parameter | Type | Description |
---|---|---|
image | SearchImage | The image to search. |
options | ImageSearchOptions | The image search options. |
Return Value
The result of a reverse image search.
See Also
- class ImageSearchResult
- class SearchImage
- class ImageSearchOptions
- class Index
- namespace GroupDocs.Search
- assembly GroupDocs.Search