Algolia search with attribute name - ruby-on-rails

Data on algolia is like this
objectID:3464542
Type:"Accelerator"
Country:"Germany"
City:null
Name:"ProsiebenSat1 Accelerator Batch #8"
I want to search any name which are in Germany. How I do that?
When I do Contact.raw_search("Batch"), I get all records even whose name include this even non-German. I want to get all those which are of specific country.

To do so, you'll first need to put the Country attribute in your attributesForFaceting list. You can do that using the REST API, your client of choice or from the Algolia Dashboard. Using the later one, go to the Indices page, select your index and click on the Display tab. Here, you could add your Country field to the Attributes for faceting list. After that, click on save and your index will be rebuild.
Now, your index is ready to filter the search queries according to the country you want. To perform the search query, you can use (using the Ruby client):
Contact.search("Batch", {
facets: ["Country"],
facetFilters: ["Country:Germany"]
})
For more informations about faceting, here is a quick intro from the FAQ and a more detailed guide in the documentation.

Related

How to query stories without parent feature link?

In a given area path, I would to get the list of stories that does not have parent feature link. How should I write the query for it?
To achieve you could change the type of your query to the Work items and Direct Links query, then choose the option to pull back all work items without any matching links. The results will still be a flat list.
In the filters for top level work items, just add a filed to specify a detail area path and choose corresponding work item type.
More details please take a look at our official here: Use direct links to view dependencies
Hope this helps.

Does Google AdWords support automatically appending a different query string to a campaign's destination URLs for ads and sitelinks?

I have an existing Google ad campaign that geotargets a particular region. The destination URL of all the ads and sitelinks have the same query string appended to it ("area=astoria").
I now need to copy this campaign to 50 other campaigns, each of which will target a different region. Each campaign will have a different value for the area key, so for instance one campaign might use "area=manhattan" and another "area=bronx".
The campaign I'm cloning has many ads and sitelinks, all of which need to have the query string changed. I know how to manually change the destination urls, but it's an enormous amount of busy work...
As a workaround, is there a way to automatically append a different query string to all the destination URLs for ads and sitelinks in a particular campaign in Google AdWords?
To answer my own question, the answer is to use a Tracking Template on the Campaign level.
To do this, click into the Campaign you want to edit and click on the Settings tab. Then open the "Campaign URL options (advanced)" section and change the Tracking URL to something like this:
{lpurl}?area=whatever
You can click the TEST button to make sure your ads work. Your sitelinks should also have the same query string appended to it. (Note that a Campaign-level Tracking Template can be overridden at the Adgroup-, Ad-, or Sitelink-level, so those more specific Tracking Templates would have to not be used for a Campaign-level Tracking Template to be used.)

Multiple select field in LocomotiveCMS?

I need to set up a field in LocomotiveCMS that is similar to Select but allows multiple selections. Something like in HTML... does LocomotiveCMS allow for that, or will I have to do some ruby coding to get that to work?
Any help would be appreciated, thanks!
Old question but still a thing.
I'm unsure whether your question relates to fields within the Locomotive CMS Back Office or on the front end so I've addressed both below.
Front End
Irrespective of whether or not you're dealing with Locomotive CMS content types, either of the following will allow selection of multiple values on the front end:
Listbox (select element with the multiple attribute)
A series of checkbox inputs with the same value in the name property
Back Office
If you need to allow selection of multiple values within the Back Office, you can do this for content types using the has_many or many_to_many content type relationships.
If you need multiple value selection outside of content types (e.g. in metafields schema) you're unfortunately out of luck.

Grails Searchable Plugin - Filtering Result Set

I am currently using Lucene. My requirement is like facebook search box. User search people and friends. But in my requirement user have privacy settings like name, location, email address are visible to everyone or only friends. He can show and hide these fields from friends and other members of the community.
I have implemented simple search on the basis of name, location and email address. But now i am modifying search on the basis of privacy settings.
Here is my scenario..
User A has privacy settings:
Name is only shown to friends
Email is shown to every one
Location is not shown to any one.
If User X type location of the User A in the search box then it should not be in the results. But if User X type Name of User A in the search box then it should be shown because User A has not restricted name and it is visible to his friends in the privacy settings.
Can you please guide me to the approach.
Let me know if i have not clearly write my requirement.
I have analysed following approaches,
1- IndexSearcher's explain method (It will be hit overall performance)
2- Explored Filters
But couldn't get much
My Approach:
Get the resultSet on the basis of name
Get the resultSet on the basis of location
Get the resultSet on the basisi of email address
Loop on each 3 result set and apply conditions related to privacy settings and exclude the items on the basis of privacy settings. And in the end merge all 3 results set.
If there is any other approach? Please share with me. Thanks.
may be you can use lucene query syntax in searchable plugin for creating lucene Query according to requirement.
you can find here or here
you can restrict seaching by overriding default property settings. You just need to apply like this....
class A {
String x
String y
String z
static searchable = [only: ['x', 'y']]
// …
}
Using this you can restrict searchable properties.

How to save result of search in DB to show it many times?

Let's imagine I have Articles in my system. I can show list of Articles based on search query which includes date ranges, category or few categories, tag or few tags, author or few authors.
So I need to show filtered list of Articles to user and give him a possibility to copy link to this list and share.
But in my case the link have to be unique hash, like this: mysite.com/articles/hsdjfh7yasdfhkfuh7sdfhidsfhkd
Do I have to store it in DB to provide this functionality? If yes - how to do that?
You can use an encryption/decryption system to generate the hash: you encrypt the search query parameters to create the hash, and you decrypt the hash when you receive it from mysite.com/articles/hsdjfh7yasdfhkfuh7sdfhidsfhkd to retrieve the search params and regenerate the list of articles.
Look at the crypt gem for some encryption/decryption algorithms.
I think in this case you need to use params in your URL to store the search query so that you can pass the results around, so your url might look like ...
mysite.com/articles/?=&cats=2,3&tags=atag,anothertag

Resources