Sitecore Search Api - How to get formatted Url - search

How can I get the formatted url from Sitecore Lucene search? I created a custom index and updated it with under root as /sitecore/content/websitename/home.
When the search results are retrieved the URL is appended with https://hostname/websitename/home/sample.aspx. I would like the url to be https://hostname/sample.aspx. Is there any setting in index config that needs to be updated?
In sites.config I already have rootPath="/sitecore/content/websitename" startItem="/home"

You can get the url in two ways:
For each result from your index, fetch the item and get the url with the LinkManager as you normally would for any item. This does mean that you need to fetch the items what will be a performance hit.
Create a computed field in your index to include the url. In your computed field, make sure the correct link is being generated. If not, you might need to check your url options and the maybe the Rendering.SiteResolving setting (true). Verify the results with a debugger (or with Luke to test the index). Remember that if you include the url in the index, you will need to update additional items when an item is renamed (or even the display name changed when that is used in the url). All children of that changed item had their urls changed as well at that point.

Related

ViewPath query parameter in SharePoint list causes CSOM to fail Lists.GetById

It seems due to a recent SharePoint Online update that their lists (when selected using the left navigation) now adds a ViewPath query parameter by default. With this change, it seems like the Provider Hosted App redirect now sends a different ListId and not the Id for the actual list. When I use CSOM to resolve the ListId it results in a "Site Pages" and not the list at all.
clientContext.Web.Lists.GetById(ListId);
This code base did work before the recent SharePoint Online update but now I cannot call my list. If I manually remove the ViewPath query parameter from the list then the redirect shows the correct ListId and CSOM resolves the correct List. The problem is I cannot expect users to manually remove that query parameter.
If I navigate to the list by using the Site Content page and not the left navigation then this query parameter is not present and my application works.
Does anyone have context or direction into how to handle this new change?
I have a similar issue on our site. Instead of modifying the list, a script web part on the initial page seems to bleed through. I have ammended the links in the lefthand nav bar in an attempt to circumvent the viewpath query being added. I put in 2 url carriage returns on the end of the link. So far so good for me.

How can I crawl but not index web pages in OpenSearchServer?

I'm using OpenSearchServer to provide search functionality on a web site. I want to crawl all pages on the site for links to follow but I want to exclude some pages from the index. I can't work out how to do this.
Specifically the website includes a shop that has its own product search and I am keeping this search for products and categories. The product pages have URLs like http://www.thesite/p/123 so I don't want to include any page like this in the search results. However some product pages reference background info pages and I want these to be included in the search index.
The problem I have is that the filter has no effect on the results - it doesn't filter out the /p/ and /c/ results. If I change the filter by unticking the negative box I get no results so it seems to be either the contents of the field or the filter criteria that is causing the problem.
I've tried adding a negative filter to the default query called search in the Query > Filter tab on the index with url:"http://www.thesite/p/*"
but it seems that wildcards are not supported for query filters although they are supported for Crawler > Exclusion list filters.
I've tried adding a new field called urlField in Schema > Fields and populating it using an analyzer configured using the Whitespace Tokenizer and a regular expression (http://www.thesite/(c|p)/). When I use the Test button it seems to generate two tokens for my test URL http://www.thesite/p/123:
http://www.thesite/p/
p
I'd hoped to be able to use the first one in a Query > Filter to exclude all the shop results and optionally be able to use the p (for product) or c (for category) if I need to search the product pages sometime in the future.
The urlShop field in the schema is set up as follows:
Indexed: yes
Stored: no (because I don't need the field back, just want to be able to filter on it)
TermVector: No
Analyzer: urlShop
Copy of: url
I've added urlFilter:"http://www.thesite/p/" to Query > Filters with the negative box ticked.
This seems to have no effect on the results when I use the default renderer.
To see whether it affects the returned results I unticked the negative box in the query filter I get no results in the default renderer. This leads me to believe that the urlShop field is not being populated but I'm not sure how to check this directly.
I would like to know whether there is an easier way to do this but if my approach makes sense in the context of OpenSearchServer please can you help me identify what's wrong?
The website is running under IIS and OpenSearchServer will be configured on the same server running in Tomcat.
Finally figured this out...
Go to query and hit edit for your configured query. Then go to the filters tab. Add a query filter like this:
urlExact:"http://myurltoexclude*"
Check the "negative" box. Click add.
Now make sure to click "save in the tiny little button on the right hand side. This is the part I missed. The URLS are still in the DB and crawl, but at least they aren't returned in results.

How can I search through a single sharepoint List in a site collection using Search Scope?

I have added a Web Address rule to a Search Scope and set the Folder url to the following for searching through a single list in site collection :-
http://svrmosstest3/sites/asmtportal/Lists/SearchList
And added this scope to the search dropdown, this search is working fine and will return results from that list only, but it returns one extra item which is an entry for the list itself which is :-
http://svrmosstest3/sites/asmtportal/Lists/SearchList/AllItems.aspx
because this will always fall under the Rule URL.
Is there any other method to create a search scope that will search only through the items of a Single Sharepoint List in a site collection ??
Please tell me ,.. if there are any sharepoint experts ??
You will most likely need to add a crawl rule to exclude that one page from being added to the index (which will then prevent it from being included in your search scope).

Why does owssvr.dll return an empty result for my list?

I am trying to use owssvr.dll and its URL API in SharePoint 2007 to get some list metadata. For most of the lists in my site of interest, I can use a url formatted like so:
http://hts-app1/compounds/_vti_bin/owssvr.dll?XMLDATA=1&List={F987723C-28A4-47D3-83D7-19094B0267DF}
I get back an xml-based list of field metadata for the default view and a list of records in the list. But when I try to use another guid for a separate list, I get an empty response from the web server. It's a 200 response code, but the other headers look like:
Connection:close
Date:Thu, 24 Mar 2011 17:38:46 GMT
MicrosoftSharePointTeamServices:12.0.0.4518
Server:Microsoft-IIS/6.0
X-Powered-By:ASP.NET
I am pretty sure the list guid is valid, since I can match it with the guid for the list I can see in the listedit.aspx page. If I also format my url like so:
http://hts-app1/compounds/_vti_bin/owssvr.dll?XMLDATA=1&List={F987723C-28A4-47D3-83D7-19094B0267DF}&Query=*
with the Query=* parameter, I can get valid xml, but it's just showing everything, and not filtered for my view, and I'd really like to have the view.
I looked in the SharePoint log file, and I couldn't find anything that looked related to this request.
So, how can I debug this? I'd really like to use a simple http GET request to get back this metadata, and owssvr.dll seemed the ideal mechanism.
You can specify a specific view as well. Like this
http://{0}/_vti_bin/owssvr.dll?Cmd=Display&List={1}&view={2}&XMLDATA=TRUE
for example:
https://foo.com/extranet/_vti_bin/owssvr.dll?Cmd=Display&List=%7B7F7AFB9D%2D6D5D%2D4626%2DBD9D%2D085957DB79AB%7D&view=%7B111EC07E%2DF648%2D443B%2D8DE6%2DB53786BE6762%7D&XMLDATA=TRUE
The absolute easiest way to get the list and view guids is to goto edit the view and snatch the list & view info directly from the address bar.
1. That supplying GUID in the querystring of your URL works for one list and does not for other is probably because the lists are on different sites. Verify that the sitename is correct and that GUID is a List ID indeed.
Be wary of the fact that, however, above applies to both SharePoint 2007 and 2010, for SharePoint 2010 additional measures might be required depending on context from which you execute commands on owssvr.dll.
2.
query=* is not a filter parameter; it shows schema as well as data for all available columns in the list, including SharePoint internal columns, which normally you never get to see in ways other than programmatic access.
3.
To get only those columns that are visible in the current default view call display command on owssvr.dll while xmldata parameter is set true; like this:
http://hts-app1/compounds/_vti_bin/owssvr.dll?Cmd=Display&List={F987723C-28A4-47D3-83D7-19094B0267DF}&XMLDATA=TRUE
Again this is for SharePoint 2007 only and depends on execution context.
4.
with the Query=* parameter, I can get
valid xml, but it's just showing
everything, and not filtered for my
view, and I'd really like to have the
view.
Oh but this is not called filtering; filtering is only based on columns values. For this use additional FilterField1 and FilterValue1 parameters.
http://hts-app1/compounds/_vti_bin/owssvr.dll"
+ "?Cmd=Display&List={F987723C-28A4-47D3-83D7-19094B0267DF}"
+ "&XMLDATA=TRUE&FilterField1=YOUR_FILTER_COLUMN_NAME&FilterValue1"
+ YOUR_FILTER_COLUMN_VALUE
Takeoff "(double quotes) and +(plus) and (returns) before testing in browser.

Problem with a custom content type

I've made a custom content type based on the "Page publishing".
In this content type, I've also made a lookup field that lists all items in a list (nothing special with that list though)
When I use my own user to look at a page made with my custom content type, no problem.
When the site is crawled, the crawler doesn't want to index it giving me the error :
“ Content for this URL is excluded by the server because a no-index attribute.”
So I logged in with the same user as the crawler, and when I try to see the page, I get this error :
The page you selected contains a list that does not exist. It may have been deleted by another user.
Still, with that user, I can see the list that is used in the lookup field without any problem...
Any idea?

Resources