
===============================
Searching for a project or file
===============================

.. contents::
   :local:
   :depth: 1

To search for projects and files, use the Search box in the
AEN navigation bar. The search provides different results
depending on which page you search from:

* On a project home page, search results include any files that
  match your search criteria within the current project.

* On any other AEN page, search results include any files that
  match your search criteria within all projects.

TIP: Your search results include only files and projects that you
can view: public projects, and private projects to which you have
a minimum of view access.


Types of files searched
=======================

The following types of files are included in search results:

* ``.py``---Python source files.

* ``.ipynb``---IPython/Jupyter notebooks.

* ``.txt``---plain text files.

* ``.md``---Markdown files.


Search indexing
===============

Files that are modified while a project is running are
automatically re-indexed shortly after the files are modified.
If you create or update a large number of files---such as cloning
a git repository or copying a directory---search results may take
several minutes to update.

Files that are modified while the project is not running are
re-indexed only after the project is started.


Using search constructs
=======================

You can use the following search constructs:

* Ordinary words will match the full-text contents of any file.

* Wildcards are permitted.

  EXAMPLE: ``John*`` will match John and Johnny.  These are
  glob patterns and are similar to their usage in the command
  line.

* Combine queries using ``AND`` or ``OR``, and group them using
  parentheses ``()``.

Regular expression patterns can be embedded in the query string by wrapping
them in forward-slashes (``/``)::

    name:/joh?n(ath[oa]n)/

The supported regular expression syntax is explained in
`the Elasticsearch reference <https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html#regexp-syntax>`_.

NOTE: Wildcards apply inside a regular expression. A query string
such as ``/.*n/`` would force the search to visit every term in the index.


Searching metadata fields
=========================

You can search in specific metadata fields:

* ``imports:name``---matches files that import the module name.

* ``uses:name``---matches files that reference the identifier
  name. Referenced names include any functions and globals
  imported from other modules, as well as the names of any
  methods invoked on any object.

* ``defines:name``---matches files that define the identifier
  name. Defined names include functions defined at global scope,
  class names, and method names within classes.

* ``acl:user``---matches files in which the named user has
  read access or higher.


Searching a project
===================

#. In the Search box, type a string of text:

   .. figure:: /img/aen-user-search_box.png
      :width: 50%

      ..

   |

   TIP: Search by glob patterns, which are similar to file
   matching in the command line.

   EXAMPLE: To find projects in the test family that are
   numbered from 00 to 99, search for ``Test-??``. To find all
   projects whose name ends with "Stats," search for ``*Stats``.

#. Press Enter.

#. In the search results, click the plus + icon above a project
   name to show a list of matching files in the selected project:

   .. figure:: /img/aen-user-search_results_expansion_icon.png
      :width: 50%

      ..

   |

   TIP: Click the project name to open the project's home page.

#. To view a file, click its file name in the matching files
   list:

   .. figure:: /img/aen-user-search_results_details.png
      :width: 50%

      ..

   |


Saving a search
===============

#. At the top of the search results, click Save this search:

   .. figure:: /img/aen-user-save_search.png
      :width: 50%

      ..

   |

The "save this search" text changes to "stored" and your search
is saved. Your saved searches are listed on your home page.


Removing a saved search
=======================

On your home page, in the Saved searches section, click X next
the saved search that you want to remove:

.. figure:: /img/aen-user-saved_searches.png
   :width: 50%

   ..

|
