How to display "ContentType" name in search results? - sharepoint

I have a MOSS site where I have created custom content types and activated those on a document library. Now I want to use a custom XSL stylesheet with search results to pull back those documents and display the name of the custom content type assigned for each one.
I know how to create managed properties and map those, etc... but can not seem to find the built-in type that would have the name I assigned to the custom content types? You would think this would be simple - but simply using a built-in one like "ContentType" returns something generic and not the name of the custom type.
Any ideas?

The default content type managed property is mapped to multiple crawled properties, with the first one usually being the mime type. I think there is a way to get all values of a property rather than just the first one in the search results xsl, but if that doesn't work out you can always add a custom managed property that only maps to the one crawled property.

Related

ListItem. Create managed property to sort result source

I have a custom contentType "Project Info" and 'Title' property is derrived from "Item".
I want to sort via Title (I'm using rest).
I have created a result source and while using the content type the I get the desired "project-items":
ContentTypeId:0x0100A5C45A8A8F7F904EA9BDB82895CC00C6*
So far so good...
I've tried to use "Refinablestring00" and map properties similar to 'Title' managed property.
Then I try to sort the result source via "refinablestring00" and it doesnt work.
Am I missing a mapped property, or what am I doing wrong?
I think the issue is the Mappings to Crawled Properties setting that is forced on the OOTB RefineableStrings. The Title Managed Property is set Include content from the first crawled property that contains information, but the RefinableStrings all have the forced setting in SharePoint Online of Include Content From All Crawled Properties. Because of this, if a search result has data for more than one of the mapped crawled properties, this could affect your sort order.
Unfortunately I think this is a big short coming to SPO when it comes to Search customization that hopefully will be addressed in the future as they learn better ways to manage Search across multiple tenancies.
What I would suggest is altering the mappings to only include one crawled property (the one that corresponds with the SharePoint list item Title field) and this should give you a result that's closer to what you're looking for.

URL for Key Filter on document list view in SharePoint 2010

I'm trying to dynamically construct URLs in an ASP.NET MVC website that point back to a SharePoint list view with a Key Filter enabled for a managed metadata field (which uses a TermSet).
If I configure a navigation hierarchy for the managed metadata field, I see the following in the URL:
TreeField=MyCategory&TreeValue=0C37852B-34D0-418E-91C6-2AC25AF4BE5B
However, if configure the managed metdata field as a KeyFilter, I see the following in the URL:
#ServerFilter=FilterField1=MyCategory-FilterValue1=247-FilterLookupId1=1-FilterOp1=In
Where does the FilterValue1 value of 247 come from? It is not the database id of the MyCategory term. It is also not present anywhere on the Term object when loading the taxonomy through the SharePoint API. Is there a way to construct the query string to use the guid for the term (or better yet, the label, which I know will be unique).
The value comes from the taxonomy hidden list. Use the following method GetWssIdSoftTerm to get the int value the above urls are using to filter the data.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.taxonomyfield.getwssidsofterm.aspx

Not sure how to programmatically filter by taxonomy metadata in my custom search webpart

I have pages in a pages library on a publishing site which have a managed metadata (taxonomy) field in their content type. I want my custom search webpart to read the taxonomy set on its parent page (I can do this fine) and then query against a specific scope using only the selected tags of the parent page as the filter (no keyword necessary).
I have tried to set FixedQuery = “owstaxIdMetadataAllTagsInfo=#0[TERM GUID]” of my CoreResultWebPart with no success... I actually gave up after I was getting 0 results and am now trying to just perform a FullTextSqlQuery.
Unfortunately it seems that even though pages with the managed metadata field are successfully being indexed, the managed property owstaxIdMetadataAllTagsInfo has no data in the results! I went ahead and made the property searchable/queryable and the property value is null.
Can you anyone confirm that I should be getting values from that managed property when there is indeed a managed metadata field on the page that is populated with data?
Note: I have tried to make my own managed property based on the managed metadata field in my site's content type -- same results.
I don't think - owstaxIdMetadataAllTagsInfo returns anything. I tried adding it to my result web part's Diaplay properties > fetched properties and got a property not recognized...related error.
So I created a separate metadata property for 'enterprise keywords' i.e. 'TaxKeyword. You need to ensure that you check the checkbox - 'Reduce storage requirements for text properties by using a hash for comparison' otherwise no results will be returned for that peroperty is you use LIKE predicate with fulltextsql.

Web Part with a custom property bound to a "choice" field from a content type?

I'm trying to make a custom property for a WebPart. The custom property should be a drop down with choices coming from a "choice" column from a content type. Is that even possible?
You have two options:
1) If your choices will never change then you can hardcode an enum with these values and use that as datatype for your custom property. SP will the automatically generate a drop down.
2) If you can't hardcode the values then you have to implement what is called an EditorPart where you can code the UI for handling entry of the custom property
You cannot data bind directly to a content type column as it does not exist as in a bindable form, only as an XML secification on the content type itself.
Better to specify the column as a lookup and databind to the list directly. However, that is not going to work well when you only want one lookup across multiple webs or site collections.
In that case create a list in a config site such as http://intranet/sites/config and code a lookup control to databind to that list. Then use the control in the webpart and in a custom field control on the content type.
A bit of work, but worth it if you require SharePoint edit control (versioning, security etc) access to the contents of the lookup and a single (changeable) source of data across the entire site.

What are the Valid values of the searchboxex AppQueryTerms enum?

I'm building a custom search page and attempting to use an existing custom search scope. I'm having success using the SearchBoxEx with the AppQueryTerms = "ContentType:'my custom content type name'" but when i try using AppQueryTerms = "Scope:'My Custom Search Scope'" I get no errors, but also no proper results. I know my scope is populated using the advanced search so I must be using AppQuwryTerms wrong.
I've searched the net over and can't find the list of allowed AppQueryTerms filters. Is this Enum know to the stackerverse?
The problem is your scope name has spaces.
This worked for me:
AppQueryTerms="Scope:"My Scope""
The values for SearchBoxEx.AppQueryTerms are not an enum. They're actually a query written in a specific language for SharePoint Searching. The syntax for SharePoint 2010 is defined by microsoft on this page. It follows the format <Property Name><Property Operator><Property Value>
Scope is your property name.
: is your property operator for
matching using the property store database.
My Scope is your
property value.
The page above states:
The property restriction must not include white space between the property name, property operator, and the property value, or the property restriction will be treated as a free-text query. The length of a property restriction is limited to 2,048 characters.
Therefore, as in HelloSharePoint's example, you have to wrap the property value in quotes if it includes spaces.
Does your custom scope appear in the web sites list of Scopes?
http://intranet/[sitecollection]/_layouts/viewscopes.aspx?mode=site
Does the scope appear in a Display Group?

Resources