人们在 SharePoint 中使用部分名称进行搜索

发布于 2024-10-03 16:37:55 字数 226 浏览 1 评论 0原文

我的雇主正在将他们的内部门户切换到 SharePoint。以前的门户网站最常用的功能之一是允许部分姓名的“人员搜索”。 SharePoint 2007 默认使用关键字搜索,仅与作为搜索项给出的确切单词进行匹配。它可以进行全文搜索,但您必须提供属性名称,例如“FirstName:tom”(当然不带引号)。这适用于编程解决方案,但不适用于最终用户。

SharePoint 2007 中有没有办法让用户使用部分姓名搜索人员?

My employer is switching their internal portal over to SharePoint. One of the highly used features of the previous portal was a 'people search' that allowed partial names. SharePoint 2007 defaults to keyword searches which only match against the exact word(s) given as search terms. It can do full-text searches but you have to provide the property name, e.g. "FirstName:tom" (without the quotes of course). That works for a programmatic solution but not for end users.

Is there a way in SharePoint 2007 to let users search for people using partial names?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我是男神闪亮亮 2024-10-10 16:37:55

我发现这个解决方案对我们来说足够有效。

将 ContentEditor Web 部件添加到目标页面并转到 HTML 编辑器按钮。添加以下 HTML 代码。它创建两个输入字段(名字/姓氏),然后创建一个查询,其中包含作为属性搜索的搜索词,这将调用全文搜索。

注意:您需要将搜索结果页面替换为适合您的配置的位置。

<script language="javascript">
//function to handle enter on keyboard
function txtWildPeopleFinder_KeyDown(e)
{
  if (e.keyCode == 13 || e.keyCode==10)
  {
    e.returnValue=false;
    DoWildPeopleSearch();
    return false;
  }
  else
    return true;
}
//escape apostrophes in search strings
function escapestr(str)
{
 return str.replace("'","%22");
}

//search function
function DoWildPeopleSearch()
{
var firstname = escapestr(document.all["firstname"].value);
var lastname =  escapestr(document.all["lastname"].value);
var url;

//search on last name
if(firstname == "")
{
 url = "/searchcenter/Pages/peopleresults.aspx?k=LastName%3A" + lastname;
 window.location=url;
 return;
}

//search on first name
if(lastname == "")
{
 url = "/searchcenter/Pages/peopleresults.aspx?k=FirstName%3A" + firstname;
 window.location=url;
 return;
}

//first and last
 url = "/searchcenter/Pages/peopleresults.aspx?k=lastname%3A" + lastname +  "%20FirstName%3A" + firstname;
 window.location=url;
 return;
}
</script>

<table cellpadding="2" cellspacing="0" border="0" width="100%" ID="Table3">
 <tr>
  <td width="80" nowrap>
   First Name:
  </td>
  <td width="100%">
   <input size="20" maxlength="100" id="firstname" name="firstname" type="text" onkeydown="txtWildPeopleFinder_KeyDown(event)">
  </td>
 </tr>
 <tr>
  <td width="80" nowrap>
   Last Name:
  </td>
  <td>
   <input size="20" maxlength="100" id="lastname" name="lastname" type="text" onkeydown="txtWildPeopleFinder_KeyDown(event)">
  </td>
 </tr>
 <tr>
  <td>   </td>
  <td>
   <input type="button" onclick="DoWildPeopleSearch()" value="Search">
  </td>
 </tr>

</table>

I found this solution that works well enough for us.

Add a ContentEditor web part to the target page and go to the HTML editor button. Add the following HTML code. It creates two input fields (firstname/lastname) and then creates a query with the search terms included as property searches which will invoke the full-text search.

Note: you need to replace the search result page with the appropriate location for your configuration.

<script language="javascript">
//function to handle enter on keyboard
function txtWildPeopleFinder_KeyDown(e)
{
  if (e.keyCode == 13 || e.keyCode==10)
  {
    e.returnValue=false;
    DoWildPeopleSearch();
    return false;
  }
  else
    return true;
}
//escape apostrophes in search strings
function escapestr(str)
{
 return str.replace("'","%22");
}

//search function
function DoWildPeopleSearch()
{
var firstname = escapestr(document.all["firstname"].value);
var lastname =  escapestr(document.all["lastname"].value);
var url;

//search on last name
if(firstname == "")
{
 url = "/searchcenter/Pages/peopleresults.aspx?k=LastName%3A" + lastname;
 window.location=url;
 return;
}

//search on first name
if(lastname == "")
{
 url = "/searchcenter/Pages/peopleresults.aspx?k=FirstName%3A" + firstname;
 window.location=url;
 return;
}

//first and last
 url = "/searchcenter/Pages/peopleresults.aspx?k=lastname%3A" + lastname +  "%20FirstName%3A" + firstname;
 window.location=url;
 return;
}
</script>

<table cellpadding="2" cellspacing="0" border="0" width="100%" ID="Table3">
 <tr>
  <td width="80" nowrap>
   First Name:
  </td>
  <td width="100%">
   <input size="20" maxlength="100" id="firstname" name="firstname" type="text" onkeydown="txtWildPeopleFinder_KeyDown(event)">
  </td>
 </tr>
 <tr>
  <td width="80" nowrap>
   Last Name:
  </td>
  <td>
   <input size="20" maxlength="100" id="lastname" name="lastname" type="text" onkeydown="txtWildPeopleFinder_KeyDown(event)">
  </td>
 </tr>
 <tr>
  <td>   </td>
  <td>
   <input type="button" onclick="DoWildPeopleSearch()" value="Search">
  </td>
 </tr>

</table>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文