Now I want to create a Full Text Search Index, which only show the Documents with the Active Time so I can order by the Time later.
I can create a Select
SELECT ARRAY v FOR v IN Times WHEN v.Active = true end as Times FROM Recipe
WHERE any Active IN Times SATISFIES true END
Order by Times[0].Value.
But now I’m stuck. How can I create a Search index with that information?
Don’t have to be.
I create a c# project where I want to use it as a search function like:
public IList<object> Find(string term, int position, int count)
{
SearchQuery query = new SearchQuery();
query.Query = new MatchQuery(term);
query.SearchParams = new SearchParams().Skip(position).Limit(count);
query.Index = "myIndex";
query.Sort("Time.Value");
var result = _bucket.Query(query);
}
Currently I only know the FTS as a solution.
Currently I think it would be already good enough if I can order the result by the array Value without excluding the inactive arrayelements
create index ix1 on Recipe (DISTINCT ARRAY v.Active FOR v IN Times END);
SELECT ARRAY v FOR v IN Times WHEN v.Active = true END as Times
FROM Recipe
WHERE ANY v IN Times SATISFIES v.Active = true END
Order by Times[0].Value;
SELECT (SELECT RAW av FORM r.Times AS av WHERE av.Active = True ORDER BY av.Value) AS Times
FROM Recipe AS r
WHERE ANY v IN r.Times SATISFIES v.Active = true END
Order by Times[0].Value;
Just to clarify here - I thought you wanted to use FTS to index the document, ie you had some interest in indexing the context of the Text field.
Do you mean to say that you don’t care about indexing the text at all?
// statement with a $1 for a positional parameter
const string statement = "select * from default where any t in tokens(Text) satisfies t=$1 end and any v in Times satisfies t.Active = true end;";
var request = new QueryRequest(statement);
query.AddPositionalParameter("test"); // set the positional parameter $1
var result = bucket.Query<dynamic>(request);
foreach(var row in result.Rows)
{
}