Sitefinity Search Control for Blog Tags

Posted by Community Admin on 04-Aug-2018 23:16

Sitefinity Search Control for Blog Tags

All Replies

Posted by Community Admin on 04-Feb-2013 00:00

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

Posted by Community Admin on 05-Feb-2013 00:00

Any idea about doings? Anybody out there? (echo echo echo)

Posted by Community Admin on 07-Feb-2013 00:00

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
            

The additional search fields work for textual fields, tags and categories save the data of a tag or category associated to a news item for example by the ID of the tag or category so the Tag ID gets indexed by default, additional implementation as the one in the blog post is required to search for tags.

Regards,
Stanislav Velikov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 20-Mar-2013 00:00

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();

The compiled query is returned as "(Title:batman Content:batman Tags:<guid>)" but it fails to return any search result. Are we missing a step in here? Are we supposed to pass the id of the tag? We tried to search by categories using:

queryBuilder.AddTerm("Categories", text);

And that works for us. But we still want it to search by tags.

Thank you,
Ernest

Posted by Community Admin on 21-Mar-2013 00:00

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();

Posted by Community Admin on 21-Mar-2013 00:00

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);

Thank you,
Ernest

Posted by Community Admin on 26-Mar-2013 00:00

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?

This thread is closed