Searching

Tip: There are many examples of searching in the FluentApiTests source code to use as examples/reference.

Managed queries

TODO: Fill this in…

Per field

_var searcher = myIndex.GetSearcher(); // Get a searcher
 var results = searcher.CreateQuery() // Create a query
 .Field("Address", "Hills") // Look for any "Hills" addresses
 .Execute(); // Execute the search

Range queries

Float Range

var searcher = indexer.GetSearcher();
var criteria1 = searcher.CreateQuery();  
var filter1 = criteria1.RangeQuery<float>(new[] { "SomeFloat" }, 0f, 100f, true, true);

Date Range

var searcher = indexer.GetSearcher();


var numberSortedCriteria = searcher.CreateQuery()
    .RangeQuery<DateTime>(new[] { "created" }, new DateTime(2000, 01,      02), new DateTime(2000, 01, 05), maxInclusive: false);

Booleans, Groups & Sub Groups

TODO: Fill this in…

Lucene queries

Native Query

var searcher = indexer.GetSearcher();  
var criteria = (LuceneSearchQuery)searcher.CreateQuery();  
//combine a custom lucene query with raw lucene query  
var op = criteria.NativeQuery("hello:world").And();

Combine a custom lucene query with raw lucene query

var criteria = (LuceneSearchQuery)searcher.CreateQuery();

//combine a custom lucene query with raw lucene query

var op = criteria.NativeQuery("hello:world").And();                                

criteria.LuceneQuery(NumericRangeQuery.NewLongRange("numTest", 4, 5, true, true));

Boosting, Proximity, Fuzzy & Escape

Boosting

var searcher = indexer.GetSearcher();


var criteria = searcher.CreateQuery("content");

var filter = criteria.Field("nodeTypeAlias", "CWS_Home".Boost(20));

Proximity

var searcher = indexer.GetSearcher();


//Arrange

var criteria = searcher.CreateQuery("content");


//get all nodes that contain the words warren and creative within 5 words of each other
var filter = criteria.Field("metaKeywords", "Warren creative".Proximity(5));

Fuzzy

var searcher = indexer.GetSearcher();
var criteria = searcher.CreateQuery();

var filter = criteria.Field("Content", "think".Fuzzy(0.1F));

Escape

var exactcriteria = searcher.CreateQuery("content");

var exactfilter = exactcriteria.Field("__Path", "-1,123,456,789".Escape());

var results2 = exactfilter.Execute();