DEV Community

GroupDocs
GroupDocs

Posted on

Looking to utilize blended characters and wildcard search in your apps?

Building smart, feature-rich and reliable applications on different development platforms for searching through various file types is no easy task. Each end user presents his own unique set of requirements which in itself could present app developers with a new challenge.

Talking about platforms, .NET is a common hunting ground for programmers around the globe to develop software applications of countless different types. For instance, a business application to index and search through data fetched from Microsoft Office and OpenOffice files, ZIP archives, email messages or PDF documents. Indexing process lets you collect, parse and store data for quicker, more accurate searching.

In a given scenario, you might need to work with multiple indices, to index more than one set of retrieved information. Therefore, you can either code a program from scratch yourself, or, you can use a dependable API to help you incorporate its features within the apps you plan to create. GroupDocs.Search for .NET is a text search API offering you necessary leverage to utilize its diverse set of features in your .NET search and indexing applications proficiently.

One of the notable features of this .NET API is the use of blended characters within your apps. The idea of this feature is that such characters help you reduce search terms and when indexed, blended characters get simultaneously interpreted as valid letters as well as separators. For instance, consider marking a hyphen (-) as a blended character, now when you index a term such as ‘green-apple’, it will save you three search terms: ‘green’, ‘apple’ & ‘green-apple’.

Following code snippet demonstrates working with blended characters:

string indexFolder = @"c:\MyIndex";
string documentFolder = @"c:\MyDocuments";
// Creating index
Index index = new Index(indexFolder);
// Marking hyphen as blended character
index.Dictionaries.Alphabet.SetRange(new char[] { '-' }, CharacterType.Blended);
// Adding documents to index
index.AddToIndex(documentFolder);
// Searching for word 'silver-gray'
SearchResults results = index.Search("silver-gray");

Another prominent feature is that of searching words containing wildcards; supporting two forms, a single wildcard arbitrary character, or a range of characters.

To check how this feature works, please refer to following code snippet:

string indexFolder = @"c:\MyIndex";
string documentFolder = @"c:\MyDocuments";
// Creating index
Index index = new Index(indexFolder);
// Adding documents to index
index.AddToIndex(documentFolder);
// Searching for words 'affect' or 'effect' in a one document with
// 'principal', 'principle', 'principles', or 'principally'
SearchResults results1 = index.Search("?ffect & princip?(2~4)");
// Searching with a single query for phrases 'assure equal opportunities',
// 'ensure equal opportunities', and 'sure equal opportunities'
SearchResults results2 = index.Search("\"?(0~2)sure equal opportunities\"");

Learn more - http://bit.ly/2AT9qXi

Oldest comments (0)