apache solr auto suggestions - django

I use solr+django-haystack
I set settings.HAYSTACK_INCLUDE_SPELLING = True
and rebuild index
I'm trying to get any suggestion using:
SearchQuerySet().auto_query('tryng ani word
her').spelling_suggestion()
But I always get None
What should I do to get at least one working suggestion ? may be I
need add some configuration into solr config or have some specific
data indexed ?

Depending on what version of solr you're using you could use EdgeNGrams or the TermsComponent (if your using 1.4). Check out these links, they should get you started in the right direction. I haven't used haystack, so I don't know if there's an easy way to use leverage these solutions in that framework.
EdgeNGrams:
www.lucidimagination.com/blog/2009/09/08/auto-suggest-from-popular-queries-using-edgengrams/
TermsComponent:
wiki.apache.org/solr/TermsComponent
www.lucidimagination.com/search/document/CDRG_ch07_7.13.3

you need to add spelling support to your default request handler in solr conf
see this please
http://wiki.apache.org/solr/SpellCheckComponent

Related

CookieAuthenticator restlet

I have built some RESTful api's with REstlet 2.3.4. I've been using HTTP_BASIC which let the browser prompt for credentials but it's time for a proper login form. I figure the easiest way to implement this is CookieAuthenticator. I can't find full working examples on github/google. I am sure i'm over looking them can someone provide a working example implementing CookieAuthenticator in Restlet?
I did get this to work after all. I have a longer answer here with some code examples. First, i was missing the fact that CookieAuthenticator is a filter and HAS the logic to handle login and logout. You need to create EMPTY ServerResources with a method annotated with #Post that has nothing in the body. Second, extend CookieAuthenticator and overwrite isLoggingIn(..) and isLoggingOut(..) with the code found in the link.
Cheers,
-ray

JSlink changes after creating site from template

I created a site with several lists and several CSR renderers for those lists. I applied the renderers to the forms via JSLink. Then I tried to save the site as template and create another one from this tempalte. All the JS links are now broken and lead nowhere.
Here is one of the JSLinks from the initial site:
<JSLink xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm">~Site/SiteAssets/FormsManagement/Js/utils.js|~Site/SiteAssets/FormsManagement/Js/paymentsFormRenderer.js</JSLink>
</WebPart>
And here is what it changed to after the template creation:
<JSLink xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm">/sites/home/test-subsite/SiteAssets/FormsManagement/Js/utils.js|/sites/home/test-subsite/SiteAssets/FormsManagement/Js/paymentsFormRenderer.js</JSLink>
These changes break all my CSR and I have no idea how to fix it. I am aware that these two links have to be equivalent, although on the recreated subsite, browser tries to load the javascript from a domain of cdn.sharepointonline.com which is wrong. (I suspect this is due to wrong relative addressing).
All the help is much appreciated! Thanks in advance.
So I figured it out. I am not sure what the problem was but I found the workaround that seems to work pretty good.
I scraped entirely the idea to use JSLink and instead I used <SharePoint:ScriptLink> tag and included the scripts that way. I wrapped my scripts so that they use ExecuteOrDelayUntilScriptLoaded([Script's closure here], 'clientForms.js');
This seems to yield the same result as using JSLink, but the tokens in JSLink are not expanded to relative urls and links are not broken. The only downside is that no one is able to modify the scripts without the Sharepoint Designer as they are no more listed in JSLink field.

Is there an easy way to fake a Sitecore Device for testing?

We have a custom device set-up in a Sitecore installation. Is there an easy way to get my desktop to render that?
I'd imagine there should be a nice parameter sc_device= we can tag onto the url, but it doesn't seem so
Using sc_device is exactly what you need. Just make sure that you use device item id, not name, e.g.:
http://localhost?sc_device={46D2F427-4CE5-4E1F-BA10-EF3636F43534}
sc_device is correct. Your problem must lie elsewhere; like suggested maybe your device has not been published etc.
Nice article documenting Sitecore Querystrings here: http://sitecoreblog.patelyogesh.in/2013/07/sitecore-query-strings-parameters.html
Did you create new device under /sitecore/Layout/Devices ? Did you also set query string field on the new device (something like ?d=m ) ? Did you publish devices,layouts, etc ?

How to make spree, rails and liqpay to work together?

I have a Rails application with Spree. I need to use Liqpay for payment and i have some troubles with it's API. I have inserted Liqpay button it is looks like
<a href="https://www.liqpay.com/api/pay?public_key=<public_key>&private_key=<private_key>&signature=<%=#sign%>&amount=<%=#order.total%>&order_id=<%= #order.id%>currency=RUB&description=Desc&type=buy&sandbox=1&pay_way=card,delayed&server_url=<my_site_api_url>&language=ru&return_url=<return_url>">
signature #sign is calculated using gem Lickpay https://github.com/leonid-shevtsov/liqpay
request = Liqpay::Request.new (<some_params>)
#sign = request.signature
this is not exectly the way, described in Liqpay docs, but that does not work too((
There is a way to make requsts to Spree without signature, but a can't cend order_id in this case, but I need it. Is there a way to calculate it correctly, or to deal without it? How I will get to know order_id in this case? Thank you!
Fiinally, made it. It is pretty easy and clear, what I had to is read documentation on Liqpay carefully. So, the first is on need to install this lib - https://github.com/liqpay/sdk-ruby
and then follow liqpay guides! One thing one need to note - is that signature should be calculated with exactly the same params, request to Liqpay Api is made.

How to use Django 1.4 with Xeround?

According to Xeround's Release Notes they don't support save points and I can't figure out how to turn off support for this in Django 1.4. Does anyone know how to accomplish this?
I had the same problem. Django seems to only check the version of the MySql when it decides whether to use savepoints or not. Xeround probably uses some non-standard database-engine that doesn't support savepoints even if the MySql version is high enough.
Quick fix (just for testing) is to just edit the django/db/backends/mysql/base.py to override the logic:
Before:
self.features.uses_savepoints = self.get_server_version() >= (5, 0, 3)
After:
self.features.uses_savepoints = False
I tested this and it didn't seem to cause problems.
Note: Editing django sources directly like this is not recommended, you probably should just create your own db backend module by subclassing or copying the mysql module and placing it inside your project. Remember to update settings.py database configuration to point to your module.