/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
/*
 * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on lists.
 *                  The index should be applied.
 * Success        : Yes
 */

drop  database test if exists;
create  database test;

use test;


create type test.AddressType as
 closed {
  number : int32,
  street : string,
  city : string
}

create type test.CustomerType as
 closed {
  cid : int32,
  name : string,
  age : int32?,
  address : AddressType?,
  interests : [string],
  children : [{
          name : string,
          age : int32?
      }
]
}

create  table Customers(CustomerType) primary key cid;

create  index interests_index  on Customers (interests) type keyword;

write output to asterix_nc1:"rttest/inverted-index-basic_olist-jaccard-check.adm"
select element c
from  Customers as c
where test.`similarity-jaccard-check`(c.interests,['databases','computers','wine'],0.700000f)[0]
;
