Working with the RESULT

Each search request returns a List<ISearchResult<T>> object where T is the EntityObject.**

ISearchResult<T> contains these key properties:

  • Content – the content parsed during search.
  • Correlation – value that represents how correlated the result is to the operand.
  • OperatorType – operator used with the operand values are AND, OR or NOT
  • Operand – pattern used to locate results.
  • Value – the Entity Framework object found. **This is T.

Below is an advanced example working with the ISearchResult<T> object returned from a search request.

   1:  //Perform two Search<T> calls, then execute a LINQ join on ISearchResult<T>.Value.CustomerID, 
   2:  //then orderby ISearchResult<T>.Value.ShipCountry
   3:  //returning a list of orders
   4:   List<ISearchResult<Order>> orders = (from customer in this._entities.Search<Customer>(@"owner AND Ana Sales ""Aria Cruz""",
   5:                                                                      (Customer c) => c.Address != string.Empty,
   6:                                                                      (Type t) => t == typeof(string) || t == typeof(int),
   7:                                                                      engine)
   8:                           join order in this._entities.Search<Order>("mexico OR canada NOT Toronto ", null, default(Func<Type, bool>), engine)
   9:                               on customer.Value.CustomerID equals order.Value.CustomerID
  10:                               orderby order.Value.ShipCountry
  11:                           select order).ToList();
  12:   
  13:  //Iterate through the results and locate only the OR results - they should be from Canada ONLY
  14:  orders.ForEach(order =>
  15:   {
  16:       if (order.OperatorType == SearchOperatorEnum.OR)
  17:             Console.Write("Canadian Order #" + order.Value.OrderID);
  18:   });

What is Result CORRELATION?

Correlation is a feature that represents how closely related the content of the Entity Framework object is to the search pattern being used. For example, if searching blog entries and the word ‘the’, one might expect to find the word ‘the’ many times. If so, it would have a low correlation. Inversely, if a proper name was searched, you might only find one match  - that record would be exactly correlated.

This allows you to easily sort and rank your searches.

Below is the correlation scale:

  • Exact – 100 percent correlated, one exact match.
  • High – 75 percent correlated – one or more and less than 25 matches.
  • Medium – 50 percent correlated – 25 or more and less than 50 matches.
  • Low – 25 percent correlated – 50 or more matches.

Last edited May 20, 2011 at 3:15 AM by jlevingston, version 1

Comments

No comments yet.