Unable to filter on a numeric field in a custom index - lucene.net

I have created a custom smart search index in Kentico but I am unable to get the index to return any results when I search against a four character year field.
I have tried adding the field to the index as an integer and used the suggested search syntax
publishedyear:10000002016
publishedyear:(int)2016
I have also added as a string and tried
publishedyear:2016
In all cases I am unable to get the search preview to return any results
Searching against an alphanumeric field such as
country:Canada
works fine.
I can view the index using the Luke tool and can confirm the expected values for publishedyear are in the index
What am I missing?

Related

Filtering a datasource using multi select wild character

Does anyone know if there is a wildcard character in AppMaker that can be used for all possible values for a field in a query?
I currently have a datasource that is being filtered based on the status using a multi-select widget. What I would like to accomplish is when all values have been de-selected I want to load all the records of that datasource without clearing the entire query in case other filters have been applied. I have it working in-a-sense that I have to explicitly construct my query as such:
widget.datasource.query.filters.Status._in = ['Status Value 1','Status Value 2','Status Value 3']
My current solution is loading the correct data when a value is selected and it correctly shows the union of the query as the values are modified. However, it selects all of the values in my multi-select; which I know is how it is supposed to work.
I tried using widget.datasource.query.filters.Status._contains = ''; and changing the assignment value to no avail. I even tried the opposite approach using _notContains
The intended outcome is to have a filtering dashboard appear much like any website where when no filtering is selected all records are displayed. I was hoping to find a wildcard character that would load all of the records. Just trying to find a way to mimic other website filters with all records when none are selected.
Thanks for the time!
So the easiest solution here is to set up your Multiselect as follows:
Options binding:
#models.YourModel.fields.Status.possibleValues
or if you don't have the possible Status values in your model then set your options binding to:
['Status Value 1','Status Value 2','Status Value 3']
Values binding:
#datasource.query.filters.Status._in
Now anytime you select any choices in the multiselect, the query will only include records that include the selected choices. And if you deselect all choices the query will ignore that filter or treat it as an empty array of values, therefore returning all records unless you applied other filters.

Can I create an index FROM another index?

I am doing various regepx_filters in an index to modify the stored index text, this from data that is originally in tagged html format (multiple zones). After I do so is is possible to now make a second index based on the first modified index that uses only one of the zones in the original index?
index_zones = Title, Author, Description
Can I, after indexing this with a custom configuration, then duplicate this index in some way that says
Create IndexB based on IndexA using ZONE:(Title) only
Say for instance I did the following regexp:
regexp_filter=(<Title>.*?ipad.*?)(<\/Title>)<Description>.*?Used.*?<\/Description>=>\1 Used\2 in order to index used into the Title Zone.
Now I want to reindex or make a new index with just the newly indexed
<Title>Bla bla ipad bla bla Used</Title>
is this possible? If not can I then update my Mysql table with the newly indexed text?
I don't think it's possible to create an index based on an existing sphinx index. I also don't think its possible to retrieve the regexp_filtered result - im pretty sure its only available to query against.
Why dont you do your regex's before sphinx indexing? For example, create a new db column ipad_used_regex and populate this with whatever scripting language you choose. Or using mariaDb with the PCRE Regex Enhancements you could build the regex match into the SQL, something like this:
SELECT Title, REGEXP_REPLACE(Title, "(<Title>.*?ipad.*?)(<\/Title>)<Description>.*?Used.*?<\/Description>", '\\1 Used\\2') as ipad_used_regex
FROM `your_table`
You could then use this SQL in your sphinx index source?

Strange field index issue with SphinxQL

I indexed a new table and did a sphinxql search:
select id from idx_Table WHERE (MATCH('#(Title) Word')
Which finds matches.
However if I try the search field in the Select command:
select id,Title from idx_Table WHERE (MATCH('#(Title) Word')
I get an error:
[Err] 1064 - index idx_Table: parse error: unknown column: Title
I checked the Title field and the matches are correct so clearly the index is indexing the field and then searching in the field correctly. So not quite sure why adding the same field to the Select command indicates it was not indexed.
You can only specify Attributes in the 'select' part, not Fields.
As a general rule, fields are matched in the full text query (the MATCH(...)), attributes are used everywhere else (select, group, order, filter etc) .
Edited to add....
So a solution is to make your title, into both an attribute and a field, so can be used as either. For strings its easy with sql_field_string.

Full-Text search on a table column issue

I have a Table that I want to search its title(nvarchar(max)) column.
But I am getting an error when I create an index over the title column so I can enable Full Text search on it.
I am going to use the Contains keyword to do the job.
Any ideas?
Thanks,
You say in the comments
When I create the index over the
column Title, I get an error stating
that you cannot create an index over a
column of this type
This sounds like you are trying to create a regular index on it not a full text index. Right click the table in SSMS and choose "Full Text Index" to set up full text indexing.
If this option is greyed out you might need to run exec sp_fulltext_database 'enable' first.

"FindAll" feature in Lucene.net

I have two fields on my web page ie: BookAuthor and BookDescription.On submit,the page searches against lucene index using the given search criteria.
If the user does not type in anything in the two fields and submits the page, how do make Lucene.Net return all the books from my index irrespective of BookAuthor and BookDescription field values?
Thanks!
the correct way to do this is to use a MatchAllDocsQuery:
http://lucene.apache.org/java/2_9_4/api/core/org/apache/lucene/search/MatchAllDocsQuery.html
I'm not sure if this is the correct way but you could add another non nullable term to the index (say BookIsPublished) with a default value and if no search term is entered by the user return all matching items on the BookIsPublished constant field.