azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Improvements to Search field helper for searchable fields

Open bryevdv opened this issue 6 years ago • 7 comments

Currently SeachableField helper accepts a type. However, this is not necessary, since only edm.String and edm.Collection(edm.String) may be searchable. Instead, SeachableField should accept a boolean flag for whether it is a collection or not:

SearchableField(name="foo)                  # type = String
SeachanbleField(name="bar, collection=True) # type = Collection(String)

cc @xiangyan99 @heaths

bryevdv avatar May 18 '20 22:05 bryevdv

Thinking more, perhaps SimpleField should similarly get a collection=true boolean? UX study participants also seemed to have a hard time composing edm.Collection with other types (they were surprised it was a function, for one).

bryevdv avatar May 18 '20 22:05 bryevdv

We could do that. The ODataType.Collection also acts like a function in other languages, but while we could still allow that, the parallel to have collection=True is nice. @brjohnstmsft and @bleroy, thoughts?

heaths avatar May 19 '20 18:05 heaths

Our type system is relatively simple today, but what if in the future we add something weird like unions? The nice thing about modeling type composition with functions is that it's trivially extensible without breaking backwards compatibility. Boolean flags, not so much.

bitsforthought avatar May 20 '20 04:05 bitsforthought

We had previously decided on collection=true in other languages, since ComplexField can only be complex or collection(complex), and searchable can only be string or collection(string). Are you suggesting we not use the collection property there, or just in this case (for consistency)?

heaths avatar May 20 '20 21:05 heaths

Just in the case of SimpleField

bitsforthought avatar May 20 '20 21:05 bitsforthought

Fair enough. Let's leave the ODataType.Collection() function-like construct we have in other languages currently.

heaths avatar May 20 '20 22:05 heaths

Fixed in #11683

xiangyan99 avatar May 29 '20 21:05 xiangyan99