I have 3 columns:
name, status, date
I want to initialize all searches to something like
and (where status is 'a' orWhere status is 'b' orWhere status is 'c')
so when somebody makes a search on the name (attribute) it would use those filters. How do I do this search in algolia using the algoliasearchHelper(js)?
Is this what Facets are for, disjunctiveFacets?
In the case you want to do status is 'a' orWhere status is 'b' orWhere status is 'c', then disjunctiveFacets is the way to do using the algoliaSearchHelper
Related
Classic example: each post has a user_id
in the creation operation, I added a field using the user relationship a field_name and backpack created for me a dropdown where to select a user name.
Fantastic, but, usernames are not in alphabetic order.
How can I sort entries in this situation?
Resolved (as documented)
I added options to the field definition
'options' => (function ($query) {
return $query->orderBy('username', 'ASC')->get();
}),
I'm implementing a rudimentary form of search for my company backoffice system. I would like to find all products names that contain all words in a search query.
So if I have these two products:
Deodorant with cucumber flavor
Deoderant with apple flavor
the search query: cucumber deoderant should match only Deoderant with cucumber flavor.
I can make it work for the query deoderant cucumber like so:
SELECT product_name FROM products WHERE name ~* regexp_replace('deoderant cucumber', '\s+', '.*', 'g');
but this approach does not work when the order is not the name in the query and the product name.
I know that this is possible by doing something like
SELECT product_name FROM products WHERE name ~* 'deoderant' AND name ~* cucumber';
but I would ideally like to stay away from string interpolation as it becomes a bit messy in my current environment.
Is there another, more elegant way to do this?
You could convert the value into an array and then use the "contains" operator #> with the words you are looking for:
SELECT product_name
FROM products
WHERE regexp_split_to_array(lower(name), '\s+') #> array['deodorant', 'cucumber'];
Online example: https://rextester.com/GNL7374
I used below rest API which I can get all items in specific folder inside SharePoint document library
/_api/web/getfolderbyserverrelativeurl('serverrelativefolderurl')/files? $expand=ListItemAllFields
I would need to filter some columns which I get under ListItemAllField , I used
"_api/web/GetFolderByServerRelativeUrl('serverrelativefolderurl')/files?$expand=ListItemAllField$filter=ACT eq '23'
"ACT" is columns name which has returned under ListItemAllField , but I get Error message "Field or property \"ACT\" does not exist." , is there any way to filter columns returned under ListItemAllField
Thanks ,
Laleh
Solution1: Instead of $ use & and try
Solution2: Check the internal name for ACT, if it varies then using internal name and check.
I can't select look up field in my SharePoint 2013 List.
also I can't filter base on a Look up field.
for example I have List with Name Test and this list has fields: Title, Company, Province
the Company and Province is look up fields I want to filter based on Province which is a look up field
using REST query it gives error:
my query:
https://TestServer/sites/AIB/OBC/_api/web/lists/getByTitle('Test')/items?$select=Province/Title&$expand=Province&$filter=Province/Title eq 'ABC'
it gives error when I put the URL in My browser for testing it gives the blow error:
<m:message xml:lang="en-US">The field or property 'Province' does not exist.</m:message>
How to filter based on a look up field in SharePoint 2013 REST ?
How to filter by lookup field value using SharePoint REST
Assume a Contacts list that contains a lookup field named Province
Option 1
When a lookup column is being added into list, its ID become accessible automatically via REST. For example, when the field named Province is added into List, Province Id could be set or get via ProvinceId property of List Item.
The following query demonstrate how to filter list items by lookup field Id (Province Id in our case):
/_api/web/lists/GetByTitle('<list title>')/items?$filter=LookupField eq <ProvinceId>
where <ProvinceId> is a province id
Option 2
In order to filter by lookup value, the query should contain $expand query option to retrieve projected fields (like Province Title). The following example demonstrates how to filter by lookup field value (by Province Title in our case):
/_api/web/lists/GetByTitle('Contacts')/items?$select=Province/Title&$expand=Province&$filter=Province/Title eq <ProvinceTitle>
where <ProvinceTitle> is a Title of Province
Use $expand like blow code:
/_api/web/lists/GetByTitle('Test')/items?$select=Province/Title&$expand=Province&$filter=Province/Title eq 'XYZ'
Mehdi jalal, I found why it was throwing that error. You need to close your ProvinceTitle with Single Quotes and there you have it. like this
Query Syntax:
/_api/web/lists/GetByTitle('Contacts')/items?$select=Province/Title,Province/ID&$expand=Province&$filter=Province/Title eq '<ProvinceTitle>'
Now this is Example Query:
/_api/web/lists/GetByTitle('Contacts')/items?$select=Province/Title,Province/ID&$expand=Province&$filter=Province/Title eq 'Detroit Province'
I've been banging my head with a problem using Sphinx: I need that the query results are returned in alphabetical order by name.
Simplistically, I have a table with two fields only: 'name' and 'address'.
When I use $sp->SetSortMode(SPH_SORT_RELEVANCE) the results come correctly in order of relevance (no alphabetical order instead)
But I need the results orderd by name, so I've tried both:
$sp->SetSortMode(SPH_SORT_ATTR_ASC,'name');
and
$sp->SetSortMode(SPH_SORT_EXTENDED,'name ASC');
Both with no success.
What am I doing wrong?
Field 'name' should be declared as attribute:
sql_attr_str2ordinal = name
You could sort it in alphabetical order using:
$sp->SetSortMode(SPH_SORT_ATTR_ASC,'name');