# Queries in text and object form This article describes two ways to create a search query: in text form and in object form. There are two ways to create a search query: in text or object form. A search query in text form is simpler but less flexible. The flexibility of queries in object form lies in the fact that it is possible to set separate search options for each subquery. In object form, you can also use, for example, a regular expression query as a part of a more complex one. All combinations of nesting search queries in object form can be found on the page [Nesting search queries in object form]({{< ref "search/net/developer-guide/advanced-usage/searching/nesting-search-queries-in-object-form.md" >}}). Each search query in text form is parsed and transformed into a query in object form before the search. Therefore, a query in object form saves the parsing step. A syntax error in a text query does not throw an exception: the search returns an empty result, and the error message is passed to the [ErrorOccurred](https://reference.groupdocs.com/search/net/groupdocs.search.events/eventhub/erroroccurred/) event of the index. Since version 26.11, the [Warnings](https://reference.groupdocs.com/search/net/groupdocs.search.results/searchresult/warnings/) property of such a result also tells the error by a line that starts with "Search failed: ", and a search with a query in object form reports its errors in the same way: the [Search](https://reference.groupdocs.com/search/net/groupdocs.search/index/search/) method throws an exception only for an argument that is not valid, for example ArgumentNullException for a query that is null, and for a disposed index. For details, see the [Search results]({{< ref "search/net/developer-guide/advanced-usage/searching/search-results.md" >}}) page. The full specification of the query language in text form is presented on the page [Query language specification]({{< ref "search/net/developer-guide/advanced-usage/searching/query-language-specification.md" >}}). Syntax with examples of all elements allowed in text search queries is presented on the page [Search operation table]({{< ref "search/net/developer-guide/advanced-usage/searching/search-operation-table.md" >}}). Each example in this documentation is usually given with the search query in text and object form. An example of a complex query in object form is given below. **C#** ```csharp string indexFolder = @"c:\MyIndex\"; string documentsFolder = @"c:\MyDocuments\"; // Creating index Index index = new Index(indexFolder); // Indexing index.Add(documentsFolder); // Creating subquery 1 - simple word query SearchQuery subquery1 = SearchQuery.CreateWordQuery("future"); subquery1.SearchOptions = new SearchOptions(); // Setting search options only for subquery 1 subquery1.SearchOptions.FuzzySearch.Enabled = true; subquery1.SearchOptions.FuzzySearch.FuzzyAlgorithm = new TableDiscreteFunction(3); // The maximum number of differences is 3 // Creating subquery 2 - numeric range query SearchQuery subquery2 = SearchQuery.CreateNumericRangeQuery(1, 1000000); // Creating subquery 3 - regular expression query SearchQuery subquery3 = SearchQuery.CreateRegexQuery(@"(.)\1"); // Combining subqueries into one query - phrase search query SearchQuery query = SearchQuery.CreatePhraseSearchQuery(subquery1, subquery2, subquery3); // Creating overall search options that limit the number of occurrences returned SearchOptions options = new SearchOptions(); options.MaxOccurrenceCountPerTerm = 1000000; options.MaxTotalOccurrenceCount = 10000000; // Searching SearchResult result = index.Search(query, options); // The result may contain the following word sequences: // futile 12 blessed // father 7 excellent // tyre 8 assyria // return 147 229 ``` ## More resources ### GitHub examples You may easily run the code from documentation articles and see the features in action in our GitHub examples: * [GroupDocs.Search for .NET examples](https://github.com/groupdocs-search/GroupDocs.Search-for-.NET) * [GroupDocs.Search for Java examples](https://github.com/groupdocs-search/GroupDocs.Search-for-Java) ### Free online document search App Along with full featured .NET library we provide simple, but powerful free Apps. You are welcome to search over your PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX and more with our free online [Free Online Document Search App](https://products.groupdocs.app/search).