Sitefinity Search Control for Blog Tags
In our template we have a Search control, Sitefinity Search control, that we want to search for blogs tags. We have the search index setup to search under blogs and we also tried to add Additional Fields for Indexing like Tag / Tags but it doens't work. It seems like the search is only searching for matches under the Title field.
Does Additional Fields for Indexing work at all? How can we make the built-in search control to search for tags?
Thank you,
Ernest
Any idea about doings? Anybody out there? (echo echo echo)
Hi Ernest,
For search in tags refer to the solution described in this blog post. It is described for Categories, but modify the code to get the Tag information
if
(category !=
null
)
queryBuilder.AddTerm(
"Tags"
, HttpUtility.UrlDecode(category));
queryBuilder.CloseGroup();
// close the category group
Hi Stanislav,
We tried this with the sampel code post from that blog post but it's still not working for us. The following below is our code inside BuildQuery of the SearchExtension class:
//get tagID (guid converted to string) using taxonomy manager
...
if (tagID != "")
queryBuilder.AddTerm("Tags", tagID);
queryBuilder.CloseGroup();
queryBuilder.AddTerm("Categories", text);
Also, are Tags and Categories indexed by default? Meaning searchable? We have a frontend page where users are given the functionality to post blogs with tags. The tags are created using the taxonomy manager. Do we need to do some extra work to index the tags? See code below:
taxon = (Taxon)TaxonomyManagerInstance.CreateTaxon<
FlatTaxon
>(Guid.NewGuid());
taxon.Title = str;
taxon.Name = Regex.Replace(uniqueNameUrl.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
taxon.Description = str;
taxon.UrlName = taxon.Name;
taxon.Taxonomy = tax;
tax.Taxa.Add(taxon);
TaxonomyManagerInstance.SaveChanges();
We got it to work. We did try the solution mentioned above but we also figured out that if we go into the control designer of the search result control. Then click Advance there's a field in there that's called SearchFields and we just had to add "Categories,Tags" into that field.
Our last problem is we want to make the search more narrow. When we search for "a" we expect a bunch of search results. It seems like the search only matches for exact word, like searching for "hello == hello". We want it to return any word that has that character or string. We have setup WordsMode of the Search control to use AnyWord but that doesn't seem to do what we want.
protected override void InitializeControls(GenericContainer container)
this.WordsMode = Telerik.Sitefinity.Services.Search.Web.UI.Public.WordsMode.AnyWord;
base.InitializeControls(container);
Can anyone explain what "WordsMode" is supposed to do? The documentation for it is lacking. Even still, not sure it would be related to what we need to do. How can we re-work the searching so that it does a partial match on text, as opposed to a "hello" == "hello" type match? The goal is to be able to search "bat" and have it return results that contain that word, e.g. Title: Batman. Can anyone provide a suggestion on how to do this?