Hot answers tagged

6

I found a blog where someone referenced the fact that you need to set the RankingModelId on the KeywordQuery. This works for the sample code you see above, as well as the custom extended CoreSearchResults web part I've built. Here is the sample code: using (SPSite spSite = new SPSite("http://localhost")) { SearchQueryAndSiteSettingsServiceProxy ...


6

I think @LeopoldLerch is on to the correct approach. Try doing the following Guid siteId = SPContext.Current.Site.ID; SPUserToken systemAccountUserToken = SPContext.Current.Site.SystemAccount.UserToken; HttpContext currentUserContext = HttpContext.Current; if (SPContext.Current != null) HttpContext.Current = null; ...


4

Try to delete the current httpcontext before elevating (but do not forget to remember it and set it back like var storedContext = HttpContext.Current; HttpContext.Current = null; <Do something> HttpContext.Current = storedContext; Because it seems to use still your curentUsers Credentials when calling the search service (which it still does in ...


4

If you have a high ratio of queries compared to deletes, then you might want to add an event receiver which calls CrawlRuleCollection.RemoveFromResults upon deletion of an item


4

Decompiling the SearchServiceApplication we see that MaxRowLimit on that application defaults to 500 and that value is passed to the query. The SearchServiceApplication MaxRowLimit can be modified as follows: PS> $ssa = Get-SPEnterpriseSearchServiceApplication PS> $ssa.MaxRowLimit = 1000 PS> $ssa.Update() PS> iisreset


4

Your filters should be: var refinementFilters = new string[] { "doc, docx" }; for (var i = 0; i < refinementFilters.Length; i++) { keywordQuery.RefinementFilters.Add("FileType:" + refinementFilters[i]); } where you add the property you want to filter on as part of the filter, not just the value. The above sample might not be the best as there is an ...


3

Phonetic search is only for people searching. This is still the case in 2013. Its more specifically called "Phonetic People Matching".


3

Without development you can try add a static query to the content search result webpart: tags:"Keyword X" or tags:"Keyword Y" or tags:"Keyword Z" - tags should be the managed property for the Enterprise Keyword column. With development you have to use the KeywordQueryClass, see: http://msdn.microsoft.com/en-us/library/ms544561%28office.12%29.aspx ...


3

The difference in the two is how they retrieve the desired data. SPSiteDataQuery executes a CAML Query towards the SharePoint Site Collection. Think of how you would use CAML Query to gather SPListItems from an SPList and scale it to a SPSite / SPWeb level. KeywordQuery utilizes the SharePoint Search Service engine to retrieve data from the Indexed ...


3

You can just add multiple Path fragments - the default logic is that they will be "ORed" if there are multiple fragments for same managed property. However, you need to make a couple of more changes to your query. Firstly, you should use colon (:) after Path so that it would return you the items under the path and not just the list itself. Secondly, you ...


3

The thing about using path in your search queries is that it treats any value as an absolute path, meaning it doesn't support relative paths. You might see examples of it working though, but it is highly unlikely you will get the desired results. It is best to make the search terms as specific as possible. E.g. specify one or more content types; or include ...


2

Yes it is. Use the following query: {{searchterms} (ContentType:A) AND (ContentType:B)} I would personally use SPContentType:


2

You need to change it as below contentclass:STS_ListItem OR IsDocument:True


2

Automatically generated Managed Properties are always Text regardless of the base property type. If you want Date type you have to create it yourself either in the SSA or in the site/site collection.


2

As mentioned by Mathew the managed property you are referencing should be text only. You need to have refinable, sortable managed property to use in your query. There are multiple refinable properties like refinabledate00 to refinabledateXX which are already available in site collection schema, you can re- purpose this property by mapping relevant crawled ...


2

It may well be a bug, but for fellow travellers, I found this in TechNet. Dealing with spaces in values Search queries use the space character to tokenize query values issued by users. When a query variable is expanded to a value that contains a space, the complete value is enclosed in double quotations. For example, for the query ...


2

Certainly late to the game here, but for the benefit of anyone else that stumbles across this page, you can use the following to reference a Managed Metadata column called MMSFieldName in the CSWP: owstaxIdMMSFieldName:{Page.MMSFieldName} The reason for this is that the token is transformed to the GUID (TaxID) rather than the plain-text label value. In the ...


2

You will need to create a custom Managed Property in your Search Service Application that maps to the crawled property ows_ContentType. Refer here and here for some help with that. (You can ignore the more advanced instructions on how to then create a refinement filter based on that, unless you want a refinement filter...) Be sure to run a full crawl ...


2

In your example you search for * in the fulltextindex in the rest api, and apply refinement filter for a date range on birthday field. Did the rest api return any refinement results for birthday? I assume you have already verified that your search schema is correct, birthday is queriable and refineable. In your c# example you don't perform the same query as ...


2

Try changing query to: query.QueryText = "IsDocument:1 Filename:\"Test*\" Path:\"http://sp2010vm/Shared Documents/*\" (LastModifiedTime:\"2011-04-25..2011-04-26\")"; You cannot filter on time in SharePoint keyword queries. It is ignored (per design i guess) For completeness: You can also choose to use the "internal" property write: instead of ...


2

you can create a scope in the Search Service Administration based on your content type or add it as a clause to the query i.e. foo AND ContentType:"My Content Type Name"


2

This worked for me. As Amit suggested, create a new managed property (CreatedDate) of type Date and Time. Map it to these Crawled Properties Basic:15(Date and Time) ows_Start_x0020_Date(Date and Time) ows_StartDate(Date and Time) Office:12(Date and Time) creationdate(Date and Time) And select Include values from a single crawled property based on the ...


1

Looks like you can pass in a keyword along with some parameters to filter the results. Example: KeywordQuery kw = new KeywordQuery(); kw.QueryText = "some keyword (DocumentDate >= 1/1/2009 AND DocumentDate <= 12/31/2009)"; will return only results that would be returned for a search on "some keyword" that have a DocumentDate somewhere in 2009. ...


1

You have to set CustomRefinementIntervals property on KeywordQuery


1

Bit of a delayed reply on this but this might help someone else - even with SharePoint 2013. If you recently changed the MaxCharactersInPropertyStoreIndex property of a managed property you'll most likely have to do a full crawl of the content source before it will take effect and be sortable.


1

I think you should go for CAML query or out-of-box filters instead of search to find items in specific lists. If you want to use search anyhow, You can create a scope for each list and create managed property for each column to search for. Then, you can see below how to form keyword query with the properties and scopes : ...


1

To exclude the Folders try adding "Size>0" to your query and see if that helps.


1

Ok I have spent some time with this and it's a reasonably complex area but. I have discovered (DOH!) that I need to be using the Managed Property name in the KQL Search. So when the crawler crawls and finds a document property, column, etc. It creates a crawled property it also creates a mapped Managed Property. So when building your KQL you need to know ...


1

Try casting the QueryCondition items from QueryConditions (which really is ends up being an IEnumerable<QueryCondition>) to KeywordCondition objects. From what I can tell, the collection is just a bunch of objects that report as the superclass, and you need to cast them to the specific class to actually access the properties that make them unique. I ...


1

This is what I ended up doing: var file = Web.GetFile(fileId); var tags = new TaxonomyFieldValueCollection(file.Item.Properties["TaxKeyword"].ToString()); var query = new SPSiteDataQuery(); // build the query var sbQuery = new StringBuilder(); sbQuery.Append("<Where><In><FieldRef Name='TaxKeyword' /><Values>"); foreach (var tag in ...



Only top voted, non community-wiki answers of a minimum length are eligible