How to get the URL query string from Azure Search Parameters - azure-cognitive-search

I used to be able to retrieve the search URL from Microsoft.Azure.Search.Models.SearchParameters by calling ToString() on an object of that type. This seems to have broken, now ToString() just returns the class name (default .net behavior).
Is there an alternate way to get the search URL from SearchParameters.
I'm on Azure search 9.0.1.
The behavior that I'm expecting was documented in a previous version here: https://learn.microsoft.com/en-us/previous-versions/azure/dn957315(v%3dazure.100)
The use case for this is that I have a search UI built on top of the azure search SDK - take a look here https://www.music4dance.net/song/advancedsearchform. The UI runs on top of an Asp.Net MVC infrastructure that uses Azure Search as the engine to produce results.
When diagnosing issues or looking into ways to extend this UI, I used to be able to run a search and see both the results and generate a URL (using the aforementioned ToString()). The search URL made it easy to plug back into the Search Explorer in the Azure Portal and tweak things until I get what I want before going back to code to make it generate the right query.

If you would like this behavior back, please create a github issue: https://github.com/Azure/azure-sdk-for-net/issues
For now you can implement it by yourself using the old code as guide: https://github.com/Azure/azure-sdk-for-net/blob/e63db195f2f2213984d4bdf81e7c495527b6217d/src/SDKs/Search/DataPlane/Microsoft.Azure.Search.Data/Customizations/Documents/Models/SearchParameters.cs#L157

Related

SharePoint 2013 - Getting SPSite.Url from SharePoint DB

I'm working directly against the SharePoint DB (I know it is highly not recommended but I need to, for several reasons).
I'm trying to get the SPSite.Url property ("http://baseurl/sites/somename") but can't figure out how to do that. I can only find and get the second part ("sites/somename") for each site.
Does any one know which stored procedures I need to use in order to get that?
The way to do that is: Retrieving the Farm Id--> Retrieving the Alternate URL Collection Ids--> Retrieving the Alternate URL Collections--> Alternate URL Matching
You can find in this link: [MS-WSSFO3]: Windows SharePoint Services (WSS): File Operations Database Communications Version 3 Protocol documentation with detailed explanation under this section:
Site Collection Lookup

REST API for SOLR analyzer

I'm going to test my SOLR analyzer and I've found instructions how to do it here: https://cwiki.apache.org/confluence/display/solr/Running+Your+Analyzer.
But I need to check several thousand of words, so I'm going to do it programmatically, not manually. Does SOLR have any REST API to run analyzer?
Thank you!
The Solr Admin page is just a set of static HTML files that uses the REST API offered by Solr behind the scenes. If you watch the Network tab in your browser's developer tools while navigating it, you'll see all the endpoints it talks to.
After doing this on the Analysis page, you can see that it makes requests to three endpoints, one to fetch the HTML, then two new requests to get the schema (for the field list) and one to perform the actual analysis:
http://localhost:8983/solr/corename/analysis/field?wt=json&analysis.showmatch=true&analysis.fieldvalue=asd&analysis.query=asd&analysis.fieldname=content

Access Sitecore DB from API in Console application

I would like to accesss the sitecore DB and items from console application like
Sitecore.Data.Database db = Sitecore.Context.Database
or
Sitecore.Data.Database db = Sitecore.Data.Database.GetDatabase("master")
how do I configure and setup my console application to access the DB as above?
Thanks Everyone for the suggestion, I am really interested in config changes, I used webservice, but it has very limited methods. For example, if I would like create an Item with the template and insert the item with prepopulated value, there is no such option. The reason I am looking for the console apporach is I would like to import the contents from XML or excel sheet and push those to the sitecore tree, eventually use the scheduled task to run the console app periodically. I do not want to copy the entire web.config and app_config. If anyone has already done this, could you please post your steps and necessary config changes?
You have two options I think:
1) Import the Sitecore bits of a website's web.config into your console application's app.config, so that the Sitecore API "just works"
I'm sure I read a blog post about this, but I can't find the reference right now. (I will have another look) But I think the simple but long winded approach is to copy all of the <sitecore/> element and all the separate files it references. I'm fairly sure you can whittle this down to a subset of the config required for data access with a bit of thinking.
2) Don't use the Sitecore API directly, connect to a web service that exposes access to it remotely.
There are a few of these that already exist. Sitecore itself exposes one, Sitecore Rocks has one, and Hedgehog TDS has one too. And you can always write your own (since any web service running inside the Sitecore ASP.Net app can make database calls and report values back and forth - just remember to consider security if this web service might end up exposed externally for any reason)
John West links to some relevant stuff here:
http://www.sitecore.net/Learn/Blogs/Technical-Blogs/John-West-Sitecore-Blog/Posts/2013/09/Getting-Data-Out-of-the-Sitecore-ASPNET-CMS.aspx
-- Edited to add --
I've not found the blog post I remember. But I came across this SO thread:
Accessing Sitecore API from a CLI tool
which refers to this blog post:
http://www.experimentsincode.com/?p=232
which I think gives the info you'll need for option 1.
(And it reminds me that, of course, when you copy the config stuff you have to copy the Sitecore binaries into your app's folder as well)
I would just like to expand on #JermDavis' post and note that Sitecore isn't a big fan of being accessed when not in a web application. However, if you still want to do this, you will need to make sure that you have all of the necessary configuration settings from the web.config and App_Config of your site in your console application's app.config file.
Moreover, you will never be able to call Sitecore.Context in a console application, as the Sitecore Context sits on top of the HttpContext which means that it must be an application and have a valid request for you to use it. What you are looking for is something more along the lines of Sitecore.Configuration.Factory.GetDatabase("master").
Good luck and happy coding :)
This sounds like a job for the Sitecore Item Web API. I use the Sitecore Item Web API whenever I need to access Sitecore data from the master database outside the context of the Content Management server or outside of the context of the Sitecore application. The Web API definitely does not allow you to do everything that the standard Sitecore API does but it can act as a good base and I now extend upon the Web API instead of writing my own custom web services whenever possible.
Thanks to JemDavis's advise.
After I copied the configuration and made changes to config section to get rid of conflicts. I copied almost all of Sitrecore, analytics and lucene dlls, it worked great.
Only thing you have to remember is, copy the app_config folder to the same location where your dlls are.
Thanks again JemDavis....

Full Text Search in GAE

I've developing a test app using GAE/J + Objectify and now trying to query my Data with Full Text Search (assuming Full Text Search is same as queries my data with GQL).
When I go to http://localhost:8888/_ah/admin/search it shows me following error:
There are no Full Text Search indexes in the Empty namespace. You need
to add data programatically before you can use this tool to view and
edit it.
I do have some data in my database to test the search.
What should I do enable that to search my data using GQL.
I believe FTS is still under a trusted tester program (I haven't seen any official docs even for the dev environment)
You might want to try signing up here:
https://docs.google.com/a/google.com/spreadsheet/viewform?formkey=dEdWcnRJUXZ2VGR3YmVsT1Q1WVB2Smc6MQ

Handling users and groups in ExtJS

I would like to try to use ExtJs for a new web app.
I need to handle users and roles to give different app features according to the connected user's role. Are there native or pre-built libraries to do this (as, for example in Drupal) or should i create it from scratch?
Build your own. Consult the following URL:
http://technopaper.blogspot.com/2010/02/access-control-in-extjs-applications.html
Particularly the first sentence of the second paragraph:
"Permissions should be always be implemented on server side and JavaScript security is always secondary"
Remember, ExtJS is a client side, Javascript-based framework. Therefore comparisons with server side frameworks such as Drupal are not valid.
I found the URL above by googling for "extjs access control". You might cast a wider net Javascript-wise by replacing ExtJS with jQuery, though my cursory examination of the results leads me to believe that you will not find much useful.

Resources