Hi Raja,

To use TextQuery you should apply @QueryTextField annotation for "name"
field in your "Fund" model.

Regards,
Igor

On Tue, Jul 23, 2019 at 9:39 PM raja24 <[email protected]> wrote:

> Hi,
>
> I'm new to Apache Ignite and doing a POC with Cache Query filter and didn't
> work.
> My code is as below and sure I'm missing the logic. Please help.
>
> Config:
> <bean class="org.apache.ignite.configuration.CacheConfiguration">
>                                         <property name="name"
> value="service-cache"/>
>                                         <property name="backups"
> value="1"/>
>                                         <property name="cacheMode"
> value="PARTITIONED"/>
>                                         <property name="atomicityMode"
> value="ATOMIC"/>
>                                         <property
> name="expiryPolicyFactory">
>                                                 <bean
> parent="expiryPolicy"/>
>                                         </property>
>                                         <property name="indexedTypes">
>                         <list>
>                             <value>java.lang.Integer</value>
>                             <value>org.apache.Fund</value>
>                         </list>
>                     </property>
>                                 </bean>
>
> Java Code:
> // get or create cache
>                 IgniteCache <Integer, Fund> cache =
> ignite.getOrCreateCache("service-cache"); // put some cache elements
>
>             final int keyCnt = 10;
>
>             // Create batch.
>             Map<Integer, Fund> batch = new HashMap<>();
>             for (int i = 0; i < keyCnt; i++){
>                 Fund fund = new Fund();
>                 fund.setName("test"+i);
>                 batch.put(i, fund);
>             }
>
>             // Bulk-store entries in cache.
>             cache.putAll(batch);
>             // Query for all people with "Master Degree" in their resumes.
>                  TextQuery txt = new TextQuery(Fund.class, "name:test1");
>
>                  try (QueryCursor<Entry&lt;Integer, Fund>> masters =
> cache.query(txt)) {
>                    for (Entry<Integer, Fund> e : masters)
>                      System.out.println(e.getValue().getName());
>                  }
>
>
> Fund Class:
> public class Fund implements Serializable{
>         private static final long serialVersionUID = 1L;
>                 private String name;
>
>
>
>         public void setName(String name) {
>                 this.name = name;
>         }
>         public String getName() {
>                 return name;
>         }
> }
>
>
> Thanks,
> Raja.
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Reply via email to