This project is read-only.

Lucene + Taxonomy... what I miss?

Topics: General
Nov 1, 2013 at 8:08 PM
I create a taxonomy and I create a taxonomy field in my content.

When I insert a new content I select the taxonomy term. If I go under Indexes and click "Rebuild" I can see "MyField, MyField-id" in indexed field list.

Background info:
I've to create a custom search engine filtering by taxonomy and so I created a new module cloning default search and, for testing purpose, I've modified "SearchService" this way:
string[] terms = { "24" };

foreach (var term in terms)
      searchBuilder.WithField("MyField-id", term).ExactMatch();
 var searchResults = searchBuilder.Search(); 
The problem:
searchResult is always the full list; no filter has been applied!

The strange thing is that if I go to the index with "Luke - Lucene Index Toolbox" quering by "MyField-id" is the only field that won't work!

There is something I miss configuring this field in Orchard?

Nov 1, 2013 at 8:31 PM
please try with an integer, and without exactmatch.
Marked as answer by danyolgiax on 11/2/2013 at 4:00 PM
Nov 1, 2013 at 9:51 PM
 int[] terms = { 24 };

foreach (var term in terms)
                searchBuilder.WithField("MyField-id", term);

var searchResults = searchBuilder.Search();
this code generates the following query but same result:
body:article* title:article* MyField-id:[24 TO 24]
if I try on Luke the result is the same: no filter and a full list!

MyField-id:[24 TO 24]
return no results!
Nov 1, 2013 at 10:20 PM
the bpdy and title will not get included if you don't use .Parse() (you shouldn't)
Nov 1, 2013 at 11:25 PM

(IndiceArticoli-id is MyField-id)
works like a charm!
IndiceArticoli-id:[24 TO 24]
return an empty list (why???)
Nov 3, 2013 at 12:00 AM
I think this solved my problem:
please try with an integer, and without exactmatch.
An error in my logic and this behavior pointed me in the wrong direction!