Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesdnn 7.1 search modulednn 7.1 search module
Previous
 
Next
New Post
9/3/2013 5:09 PM
 

I don't see UniqueKey being passed Jurgen2. There must be exceptions being logged under Portals\_default\logs folder


Ash Prasad
Director of Engineering
DNN Corp.
 
New Post
9/3/2013 5:19 PM
 

@Guss

1. Correct

2. Use the  beginDate supplied in the method. This is in Utc. You should be able to write query to return records that have changed since this date.

3. You can continue to pass just the QueryString in the QueryString property of the SearchDocument and platform will construct the full url based on TabId and ModuleId.

Have a look into my blog here:  http://www.dnnsoftware.com/community-...

more to follow soon.


Ash Prasad
Director of Engineering
DNN Corp.
 
New Post
9/10/2013 4:25 AM
 
I'm sorry for my late response but I was on vacation. I've checked my log file and indeed there is a error logged when trying to search. It doesn't give me much information tough about what the problem could be:

2013-09-10 10:21:18,717 [Jurgen][Thread:25][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.NullReferenceException: Object reference not set to an instance of an object.
at DotNetNuke.Web.InternalServices.SearchServiceController.IsWildCardEnabledForModule()
at DotNetNuke.Web.InternalServices.SearchServiceController.Search(String search, String culture, Int32 pageIndex, Int32 pageSize, Int32 sortOption)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.b__c(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.b__4()
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)

So I have a nullreferenceexception but where does it come from.
 
New Post
9/10/2013 9:55 AM
 

So here is complete example, for everyone for who it is easier to "follow-by-example". 

  1. I first create a seperate class called StudentsController (my view is called Students)
  2. Then inherit from ModuleSearchBase
  3. Then I have a datatable that is being filled with my student data from the database 
  4. Then inside GetModifiedSearchDocuments, I loop through all the records in the datatable and create a searchDoc for each.
  5. Then searchDocuments is the collection of the searchDoc('s)

using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Search.Entities;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace MySampleApplication
{
public class StudentsController : ModuleSearchBase
{
#region ModuleSearchBase
public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo modInfo, DateTime beginDate)
{
var searchDocuments = new List<SearchDocument>();
DataTable tbl = new DataTable();
tbl = DocumentData();
foreach (DataRow r in tbl.Rows)
{
Dictionary<string, string> keywords = new Dictionary<string, string>();
keywords["MiddleName"] = r["MiddleName"].ToString();
IEnumerable<string> tags = new string[] { r["Name"].ToString(), r["Surname"].ToString(), r["RegistrationNumber"].ToString() };
var searchDoc = new SearchDocument
{
UniqueKey = String.Format("Student{0}", r["StudentID"].ToString()),
QueryString = String.Format("id={0}", r["StudentID"].ToString()),
PortalId = modInfo.PortalID,
Keywords = keywords,
Tags=tags,
Permissions = "Student Viewers",
Title = String.Format("{0} {1}", r["Nickname"].ToString(), r["Surname"].ToString()),
AuthorUserId = Convert.ToInt32(r["ModifiedByUser"].ToString()),
Description = String.Format("{0} {1} {2} - {3}", r["Name"].ToString(), r["Surname"].ToString(), r["RegistrationNumber"].ToString(), r["Membership"].ToString()).Replace(" ","&nbsp;"),
ModifiedTimeUtc = Convert.ToDateTime(r["ModifiedDate"].ToString()).ToUniversalTime()
};
searchDocuments.Add(searchDoc);
}
return searchDocuments;
}
#endregion

#region Getting the data needed for search documents
private DataTable DocumentData ()
{
DataTable tbl = new DataTable();
string sql = @"SELECT l.StudentID, l.RegistrationNumber, l.Name, l.MiddleName, l.Surname, ISNULL(l.Nickname, l.Name) AS NickName, l.ModifiedByUser, l.ModifiedDate .....
FROM dbo.vtLede l....;
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
conn.Open();
using (SqlDataReader myReader = cmd.ExecuteReader())
{
tbl.Load(myReader);
}
}
}
return tbl;
}
#endregion

}
}

 
New Post
9/10/2013 10:08 AM
 
Description = String.Format("{0} {1} {2} - {3}", r["Name"].ToString(), r["Surname"].ToString(), r["RegistrationNumber"].ToString(), r["Membership"].ToString()).Replace(" "," "),

 

An what is that last Replace statement above?, well, I do not like the way where code tries to "invent" what the description should be by breaking my description into unreadable snippets of text. 

THEREFORE, the only way I have found to overcome where my description is processed by the build-in "snippets" routine in the search results, is to force my description as a big piece of text, without space ( Replace(" "," ")  ). I wish there was an nicer way, but could not find something.

Permissions

The permissions property i have found very confusing. The documentation state either roles or users. I could not get user(s) to work, neither roles. Just role (single role) does work.

Further, the type is string, ??? That is confusing.... if multiple roles can be passed, why is it a string, and not some kind of array (list etc). Is a csv string what is expected, no, cause that does not work.

Not to allow multiple roles is a  problem for modules that list multiple content (records in this case). Its find for TEXT, because you can either view it or not, but for records, it would have been really nice if you could specify what users can view which records by passing a list of values or array into the Permission property.

Multiple roles is not helpful, (can't create a role for each user).

Except for the above mentioned, the rest is easy, and its by miles faster than the old DNN search (in indexing and finding results).

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesdnn 7.1 search modulednn 7.1 search module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out