Searching Non-Content Objects

In Brightspot, non-content objects derive directly from Record and typically support Content-derived objects. For example, you can have a content-carrying Article class that references a Record-derived WriterContract class. This class represents the personal information of freelance writers who contribute articles.

public class WriterContract extends Record {

   @Indexed
   private String name;

   @Indexed
   private String address;

   private StorageItem contract;

   // getters and setters
}

Record-derived objects can only be searched by content type in the content picker, not in the search panel. In the content picker, only the first indexed field of a Record-derived object is searchable. All other indexed fields are ignored by default.

For example, if you click the Contract field in the content edit form for Article …

../../../_images/article.png

… the content picker shows all of the WriterContract objects. Because name is the first indexed field in the WriterContract class, you can only search on name in the content picker.

../../../_images/content-picker1.png

You can change Brightspot’s default search behavior for non-content objects in the following ways:

  • Use the @Content.Searchable annotation, which makes all indexed fields of a Record-derived class searchable, from both the search panel and the content picker.
  • Use the @Recordable.LabelFields annotation in conjunction with the @Indexed annotation.

All indexed fields listed in the @LabelFields annotation are full-text searchable in the content picker.

In the following example, the indexed fields of name and address are listed in the @LabelFields annotation, thereby making them both searchable.

@Recordable.LabelFields({"name", "address"})
public class WriterContract extends Record {

   @Indexed
   private String name;

   @Indexed
   private String address;

   private StorageItem contract;

   // getters and setters
}

In the content picker, you can now search on the address field as well as the name field to narrow the selection of WriterContract objects.

../../../_images/content-picker2.png