There are two entities and first entity is referred into second entity.

Entity 1:

```
    @Indexed
    public abstract class Yesh implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private Long id;

    @Fields({ @Field(index = Index.YES, store = Store.NO), @Field(name = "YeshName_for_sort", index = Index.YES, analyzer = @Analyzer(definition = "customanalyzer")) })
    @Column(name = "NAME", length = 100)
    private String name;

    public Yesh () {
    }

    public Yesh (Long id) {
        this.id = id;
    }

    public Yesh (Long id) {
        this.id = id;

    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "com.Prac.Yesh[ id=" + id + " ]";
    }

    }

```

Entity 2:

```
    public class Kash implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private Long id;

    @IndexedEmbedded
    @ManyToOne
    Yesh yes; //Contain reference to first entity

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Yesh getYes() {
        return yes;
    }

    public void setId(Yesh yes) {
        this.yes = yes;
    }
    }

```

There is no annotation in Entity 2 on reference Yesh; Entity 1 have field annotated with name "YeshName\_for\_sort". But when i try to access above field as given in following example:

Main Class:

```
FullTextEntityManager ftem =    Search.getFullTextEntityManager(factory.createEntityManager());
 QueryBuilder qb = ftem.getSearchFactory().buildQueryBuilder().forEntity( Kash.class ).get();
 org.apache.lucene.search.Query query = qb.all().getQuery(); 
 FullTextQuery fullTextQuery = ftem.createFullTextQuery(query, Kash.class);

 //fullTextQuery.setSort(new Sort(new SortField("YeshName_for_sort", SortField.STRING, true)));
  The above statement is not working and i have also tried to replace YeshName_for_sort with 'yes' reference but it is not working. 

 fullTextQuery.setFirstResult(0).setMaxResults(150);
 int size = fullTextQuery.getResultSize();
  List<Yesh> result = fullTextQuery.getResultList();
  for (Yeshuser : result) {
   logger.info("Yesh Name:" + user.getName());
   }

```

Sorting does not work. I also tried to change statements like:

```
    ftem.createFullTextQuery(query, Kash.class, Yesh.class); //added entity 1

```

or 

```
   fullTextQuery.setSort(new Sort(new SortField("yes.name", SortField.STRING, true))); // Added property name for Yesh yes;

```

but it is not working.

What annotations need to be implemented in entities or any changes in main program to access the field for sorting?