Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Portal Search with "OR" and "AND"

  Asked By: Haresh    Date: Jan 06    Category: Sharepoint    Views: 1248

I have recently tested the search tool. It seems to me that if I have more
than 1 word or if I use "AND" operator (generally known as an operator), the
search process will always use a "OR" in the search string. However, I would
like to make my search with a "AND", as this

project AND failed

This would get all document with the word "project" AND the word "failed" in
the document. not one or the other.

Somebody has a solution?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Roxanna Hendricks     Answered On: Jan 06

We implemented the code attached as an alternate search  web part for
Sharepoint version 1 and had good results. I will attach as text
files.Just rename to dwp when you need to use them.

 
Answer #2    Answered By: Stacia Guy     Answered On: Jan 06

I'll paste the code instead.

Advanced:

<?xml version="1.0"?>
<WebPart xmlns="urn:schemas-microsoft-com:webpart:">
<Title>EnterpriseSearch_Advanced</Title>
<Description></Description>
<Content>Function GetContent(nod)
On Error Resume Next

GetContent = "&nbsp;"

Dim fOwnerDrawSearchBox
fOwnerDrawSearchBox = GetPerPageCachedItem("OWNER_DRAW_SEARCH_BOX")
If Err.Number <> 0 Then ClearCurrentErrorContext() : Set
fOwnerDrawSearchBox = False
If fOwnerDrawSearchBox Then
nod.SelectSingleNode("IsIncluded").Text = "0"
Exit Function
End If

Dim strOutput

Dim strPrevCategoryKeywordConstraints, strPrevDocumentKeywordConstraints,
strPrevPropConstraints
Dim strAdvancedForm, strOldScope, strOldKeywords, strStartRow,
strSearchScope, strWasAdvForm
Dim strCurrentUrl, strWorkspaceName, strCarriedBestBetCount,
strSubscribedSearch
Dim strLastProfile, strLastDateUsed, strLastDateCount, strLastDateRef,
strLastDateQuanta, strSwitch

strCurrentUrl = GetCurrentDataUrl()
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
returned from GetCurrentDataUrl." : Exit Function

strWorkspaceName = GetWorkspaceName()
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
returned from GetWorkspaceName." : Exit Function

strAdvancedForm = GetValueFromRequestFormField( g_strSearchShowAdvancedId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the strAdvancedForm from form post." : Exit Function

strWasAdvForm = GetValueFromRequestFormField( g_strSearchWasAdvancedId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the strWasAdvForm from form post." : Exit Function


If Len(strAdvancedForm) <= 0 Then
strAdvancedForm = "true"
strWasAdvForm = "true"
End If

strPrevCategoryKeywordConstraints = GetValueFromRequestFormField(
g_strPreviousCategoryKeywordConstraintsId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the strPrevCategoryKeywordConstraints from form post." : Exit Function

strPrevDocumentKeywordConstraints = GetValueFromRequestFormField(
g_strPreviousDocumentKeywordConstraintsId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the strPrevDocumentKeywordConstraints from form post." : Exit Function

strPrevPropConstraints = GetValueFromRequestFormField(
g_strPreviousPropertyConstraintsId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the strPrevPropConstraints from form post." : Exit Function

strStartRow = GetValueFromRequestFormField( g_strStartResultsRowId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the strStartRow from form post." : Exit Function

strOldScope = GetValueFromRequestFormField( g_strSearchScopeFieldId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the oldscope from form post." : Exit Function

strOldKeywords = GetValueFromRequestFormField(
g_strSearchHiddenKeywordFieldId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the strOldKeywords from form post." : Exit Function

strCarriedBestBetCount = GetValueFromRequestFormField(
g_strCarriedBestBetCountFieldId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the strCarriedBestBetCount from form post." : Exit Function

strSubscribedSearch = GetValueFromRequestFormField( g_strSubscribedSearchId
)
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the strSubscribedSearch from form post." : Exit Function

strLastProfile = GetValueFromRequestFormField( g_strProfileId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the last profile from form post." : Exit Function

strLastDateUsed = GetValueFromRequestFormField( g_strDateSearchUsedId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the last date quanta from form post." : Exit Function

strLastDateCount = GetValueFromRequestFormField( g_strDateScopingCountId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the last date count from form post." : Exit Function

strLastDateRef = GetValueFromRequestFormField( g_strDateScopingReferenceId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the last date referrence from form post." : Exit Function

strLastDateQuanta = GetValueFromRequestFormField( g_strDateScopingQuantaId )
If Err.Number <> 0 Then SaveCurrentErrorContext "GetContent() - Error
getting the last date quanta from form post." : Exit Function

Dim strTopLevelCatFolder, strTopLevelDocFolder, strPortalPath,
strWorkspacePath, fInCategory, fInFolder, strScopeQuery, strAutoCatEnabled
strTopLevelCatFolder = GetWorkspaceUrl() & "/" &
GetWorkspacePropertyByUri(g_cdostrURI_CategoriesFolder)
strPortalPath = GetWorkspaceUrl() & "/" &
GetPortalRootDashboardName() & "/"
strWorkspacePath = GetWorkspaceUrl() & "/"
If LCase( GetWorkspacePropertyByUri(g_cdostrURI_IsSuggestedCategoryUsed) ) =
"true" Then
strAutoCatEnabled = "true"
Else
strAutoCatEnabled = "false"
End If
fInCategory = False
fInFolder = False
strScopeQuery = ""
If InStr( LCase( strCurrentUrl ), LCase( strTopLevelCatFolder ) & "/" )
Then
If Len( strTopLevelCatFolder & "/" ) < Len( strCurrentUrl ) Then
.
.
.
.
.
GetContent = strOutput
End Function</Content>
<ContentLink></ContentLink>
<XSL></XSL>
<XSLLink></XSLLink>
<MasterPartLink></MasterPartLink>
<RequiresIsolation>0</RequiresIsolation>
<ContentType>1</ContentType>
<IsIncluded>1</IsIncluded>
<AllowRemove>1</AllowRemove>
<IsVisible>1</IsVisible>
<FrameState>0</FrameState>
<AllowMinimize>0</AllowMinimize>
<HasFrame>0</HasFrame>
<Zone>4</Zone>
<PartOrder>1</PartOrder>
<PartImageSmall></PartImageSmall>
<PartImageLarge></PartImageLarge>
<CustomizationLink></CustomizationLink>
<CacheBehavior>0</CacheBehavior>
<CacheTimeout>0</CacheTimeout>
<PartStorage></PartStorage>
<Namespace></Namespace>
<Height></Height>
<Width></Width>
<DetailLink></DetailLink>
<HelpLink></HelpLink>
</WebPart>

 
Answer #3    Answered By: Kacy Bright     Answered On: Jan 06

I'm using SPS 2003 on windows server 2003.

Documents are in a SQL 2000 Standard edition on the same server as SPS 2003.

 
Didn't find what you were looking for? Find more on Portal Search with "OR" and "AND" Or get search suggestion and latest updates.




Tagged: